i generated admin in Symfony 1,4. I have there DoctrineChoice. I would like set this list select in action.class.php.
I copied executeNew to action.class.php, but i dont can set default value on load page.
$this->form = $this->configuration->getForm();
$this->news = $this->form->getObject();
$this->form['author_id']->getWidget()->setOption('choices', '2');
doesnt work. Is this possible?
This code should work:
$this->form['author_id']->getWidget()->setDefault(2);
But I have to say that if you want it clean, this code belong to the Form class, not the action.
or just simply like this in lib/form
$this->setDefault('fieldname', $value);