如何使用树枝添加所需的表单行
我已经使用了此代码,但是在我忽略它时无法正常工作
TypeInfo visitDotExpression(MemberAccess exp) {
TypeInfo leftType = visit(exp.leftOperand);
if (leftType.isStructType()) {
if (leftType.memberTypes.containsKey(exp.memberName)) {
return leftType.memberTypes.get(exp.memberName);
} else {
// produce a type error because the struct doesn't have a member
// with the given name
}
} else {
// Produce a type error because left operand of `.` is not a struct
}
}
控制器
{{ form_row(form.prenom,{'attr': {'required': 'required'} }) }}
答案 0 :(得分:1)
您应该在表单的构建中指定它:
->add('prenom', TextType::class, [
'label' => 'customer.edit.firstname',
'required' => true
])