how to set default value in backend form?
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()->setOptio开发者_如何转开发n('choices', '2');
doesnt work. Is this possible?
or just simply like this in lib/form
$this->setDefault('fieldname', $value);
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.
精彩评论