Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The good way to translate a item from config array ?
- Here is my form with multioptions for my selectbox:
- <?php
- namespace Candidat\Form;
- use Zend\ServiceManager\FactoryInterface;
- use Zend\ServiceManager\ServiceLocatorInterface;
- use DoctrineORMModule\Form\Annotation\AnnotationBuilder;
- use DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity;
- class EtatcivilFormFactory implements FactoryInterface
- {
- /**
- * @param ServiceLocatorInterface $serviceLocator
- * @return Message
- */
- public function createService(ServiceLocatorInterface $serviceLocator)
- {
- $em = $serviceLocator->get('doctrine.entitymanager.orm_default');
- $config = $serviceLocator->get('srv.config');
- $fqcn = 'Candidat\Entity\Etatcivil';
- $builder = new AnnotationBuilder($em);
- $form = $builder->createForm($fqcn);
- $form->setHydrator(new DoctrineEntity($em,$fqcn));
- $form->get('civiliteId')->setValueOptions($config->get('candidat','etatcivil','sexe'));
- $validation = new \Application\Form\Fieldset\ValidationFieldset('validation');
- $form->add($validation);
- return $form;
- }
- }
- Here is my config array:
- return array(
- 'Candidat' => array(
- 'etatcivil' => array(
- 'sexe' => array(
- 1 => "r_sexe_1",
- 2 => "r_sexe_2",
- ),
- ),
- );
- Here is are my translations (from ini file)
- r_sexe_1 = "Homme"
- r_sexe_2 = "Femme"
- Here is the view script:
- <?php $sexe = $this->translate('r_sexe_'.$this->id_sexe,'candidat'); ?>
- <span class='textMarron11'>Sexe :</span>
- <span class='textVert12'><?php echo $sexe; ?></span>
- Is it the correct way to do this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement