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

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.

When I add required => true, it throws a SF2 exception and does not do any FE validation like it does with the name property.

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' => false,
                'label'    => false,
            ))
        ;
    }

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s