用细枝提交忽略必需的表格行

时间:2019-03-13 11:00:54

标签: html twig

如何使用树枝添加所需的表单行

我已经使用了此代码,但是在我忽略它时无法正常工作

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'} }) }}

1 个答案:

答案 0 :(得分:1)

您应该在表单的构建中指定它:

->add('prenom', TextType::class, [
            'label' => 'customer.edit.firstname',
            'required' => true
        ])