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?
或者只是在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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.