View difference between Paste ID: qygXKXSF and ZdM4SUKp
SHOW: | | - or go back to the newest paste.
1
The good way to translate a item from config array ?
2
3
Here is my form with multioptions for my selectbox:
4
<?php
5
namespace Candidat\Form;
6
7
use Zend\ServiceManager\FactoryInterface;
8
use Zend\ServiceManager\ServiceLocatorInterface;
9
use DoctrineORMModule\Form\Annotation\AnnotationBuilder;
10
use DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity;
11
12
class EtatcivilFormFactory implements FactoryInterface
13
{
14
    /**
15
     * @param  ServiceLocatorInterface $serviceLocator
16
     * @return Message
17
     */
18
    public function createService(ServiceLocatorInterface $serviceLocator)
19
    {    	
20
        $em = $serviceLocator->get('doctrine.entitymanager.orm_default');
21
        $config  = $serviceLocator->get('srv.config');
22
        $fqcn = 'Candidat\Entity\Etatcivil';
23
        
24
        $builder = new AnnotationBuilder($em);
25
        $form = $builder->createForm($fqcn);   
26
        $form->setHydrator(new DoctrineEntity($em,$fqcn));        
27
        $form->get('civiliteId')->setValueOptions($config->get('candidat','etatcivil','sexe'));
28
         
29
        $validation = new \Application\Form\Fieldset\ValidationFieldset('validation');
30
        $form->add($validation);        
31
        return $form;
32
    }
33
}
34
35
Here is my config array:
36
return array(
37
'Candidat' => array(
38
		'etatcivil' => array(
39
			'sexe' => array(
40
					1 => "r_sexe_1",
41
					2 => "r_sexe_2",
42
			),
43
		),
44
);
45
46
Here is are my translations (from ini file)
47-
<span class='textVert12'><?php echo $sexe; ?></span>
47+
48
r_sexe_2 = "Femme"
49
50
Here is the view script:
51
<?php $sexe = $this->translate('r_sexe_'.$this->id_sexe,'candidat'); ?>
52
<span class='textMarron11'>Sexe :</span>
53
<span class='textVert12'><?php echo $sexe; ?></span>
54
55
Is it the correct way to do this?