Making a A2lix translation field required in the front end in a Symfony form

守給你的承諾、 提交于 2019-12-07 19:07:17

问题


Is there a way to make a A2lix translation field required and validated through the front-end in a Symfony form? I have tried adding a property of presentation and translations to my validation.yml file, but to no avail.

I find that when I don't enter anything in the translation field the form doesn't submit, but nothing happens. No FE or BE error.

My form:

/**
 * {@inheritdoc}
 */
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('translations', 'a2lix_translationsForms', array(
            'form_type' => new CourseGuideTranslationType($this->dataClass . 'Translation', $this->validationGroups),
            'label'     => 'crmpicco.course_guide.name',
            'required'  => true
        ))
        ->add('name', 'text');
}

In validation.yml:

CRMPicco\GolfBundle\Entity\CourseGuide:
    properties:
        name:
            - NotBlank: ~

CourseGuideTranslationType.php:

class CourseGuideTranslationType extends AbstractResourceType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('presentation', 'text', array(
                'required' => true,
                'label'    => false,
            ))
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'crmpicco_course_guide_translation';
    }
}

来源:https://stackoverflow.com/questions/33413293/making-a-a2lix-translation-field-required-in-the-front-end-in-a-symfony-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!