doctrine2 - Doctrine Module objectSelect setvalue not working -


i have simple question regarding doctrine modules object select.

i have simple objectselect form element

       $this->add(array(             'name' => 'timezone',             'type' => 'doctrinemodule\form\element\objectselect',             'options' => array(                 'label' => _('timezone:'),                 'label_attributes' => array('class' => 'required'),                 'object_manager' => $this->getentitymanager(),                 'target_class' => 'application\entity\timezones',                 'property' => 'timezone',                 'is_method' => true,                 'find_method' => array(                     'name' => 'findall',                 ),             ),         )); 

now want select option default, have used setvalue method not working.

$this->get('timezone')->setvalue(335); 

does know why is?

many in advance.

i figured out why wasn't working.

in controller binding form doctrine entity empty. overriding values set. added values in controller after form bound , fixed issue.

$entitymanager = $this->getentitymanager(); $site = new sites($this->getservicelocator()); $form = new addsiteform($this->getservicelocator()); $form->sethydrator(new doctrineobject($entitymanager)); $form->bind($site); $form->get('timezone')->setvalue(335); $form->get('currencycode')->setvalue('gbp'); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -