<?php echo $form['field']->render() ?>
是否可以设置此选择框的选定选项?
或者,这必须在创建此表单的类中完成吗? 字段的创建已完成:
public function configure() { $this->widgetSchema['field'] = new sfWidgetFormSelect( array("choices" => array('1' => 'test1','2' => 'test2') ) ); }
是的,您确实应该通过以下方式设置相应的表单值 bind() default
bind()
default
public function configure() { $this->widgetSchema['field'] = new sfWidgetFormSelect(array( "choices" => array('1' => 'test1','2' => 'test2'), 'default' => 2)); }
希望我已经回答了你的问题。