S
S
simonnidze2015-09-08 12:32:23
Doctrine ORM
simonnidze, 2015-09-08 12:32:23

How to make a multilingual form in ZF2?

Hello!
There is a following form in ZF2!
Question #1: What is the best way to translate label and placeholder values ​​for form elements?
Question #2: What is the best algorithm to use to translate the option select values ​​in this case into the language set in the locale?
I will be glad to any advice!!!

class CatForm extends Form implements ObjectManagerAwareInterface
        {
            protected $objectManager;

            public function __construct(ObjectManager $objectManager)
            {
                $this->setObjectManager($objectManager);
                $this->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods);
                $hydrator = $this->getHydrator();
                $hydrator->addStrategy('breed', new BreedStrategy($objectManager));
                parent::__construct('catForm');


                $this->add(array(
                    'type' => 'DoctrineModule\Form\Element\ObjectSelect',
                    'name' => 'breed',
                    'options' => array(
                        'object_manager' => $objectManager,
                        'target_class'   => 'Cat\Entity\GuideBreeds',
                        'property'       => 'title',
                        'label'       => 'Select Breed',
                        'is_method'      => true,
                        'empty_option'   => 'Choose cat breed',
                        'find_method'    => array(
                            'name'   => 'findBy',
                            'params' => array(
                                'criteria' => array(),
                                'orderBy'  => array('title' => 'ASC'),
                            ),
                        ),
                    ),
                ));
               
             $this->add(array(
                    'name' => 'local_home_name',
                    'type' => 'Text',
                    'options' => array(
                        'property' => 'localHomeName',
                        'label' => 'Local Home Name',
                    ),
                    'attributes' => array(
                        'placeholder' => 'Enter cat\'s local home name',
                    ),
                ));                
                $this->add(array(
                    'name' => 'submit',
                    'type' => 'Submit',
                    'attributes' => array(
                        'value' => 'Go',
                        'id' => 'submitbutton',
                    ),
                ));
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Андрей Дегтярук, 2015-12-08
@hlogeon

framework.zend.com/manual/current/en/modules/zend....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question