[AdminBundle] with a2lix / TranslationFormBundle

679 views
Skip to first unread message

marc morales

unread,
Aug 21, 2012, 11:07:41 AM8/21/12
to sonata...@googlegroups.com

Hello,

I'm using a2lix / TranslationFormBundle to i18n suport, that adds a new type in your form named "translations" to facilitate the use of the Translatable Doctrine extension.

The bundle has this functrion to build form:

class TranslationsLocaleType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        foreach($options['fields'] as $fieldName => $fieldConfig) {
            $fieldType = $fieldConfig['type'];
            unset($fieldConfig['type']);
            
            $builder->add($fieldName, $fieldType, $fieldConfig);
        }
    }

Then in the class to generate de Sonata Admin form I put:

public function configureFormFields(FormMapper $formMapper)
{
       $formMapper
            ->add('title')
            ->add('description')
            ->add('translations', 'translations',array(
                'by_reference' => false,
                'locales' => array('fr', 'en'),
            'fields' => array(                          // [Optionnal] Fields configurations. If not, auto detection from translatable annotations
            'title' => array(
            'label' => 'name',                   // Custom label
            'type' => 'textarea'                // Custom type : text or textarea. If not, auto detection from doctrine annotations
            ),
            'description' => array(
            'display' => false
            )
           
            )));      

}
But i obtain this error:

CRITICAL - Symfony\Component\OptionsResolver\Exception\InvalidOptionsException: The option "fields" does not exist. Known options are: "attr", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_protection", "csrf_provider", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "locales", "mapped", "max_length", "pattern", "post_max_size_message", "property_path", "read_only", "required", "sonata_admin", "sonata_field_description", "translation_domain", "trim", "validation_constraint", "validation_groups", "virtual" (uncaught exception) at /home/marc/workspace/LoPati2/vendor/symfony/symfony/src/Symfony/Component/OptionsResolver/OptionsResolver.php line 255


What  Can I do? When is the problem?

Thanks

Regards

David Allix

unread,
Aug 29, 2012, 4:21:15 AM8/29/12
to sonata...@googlegroups.com
For interested people, Marc had created the issues https://github.com/a2lix/TranslationFormBundle/issues/3

Regards.
Reply all
Reply to author
Forward
0 new messages