开发者

How to set sfWidgetFormInputCheckbox default to false inside form class?

I've got a form class with a checkbox widget:

$this->setWidgets(开发者_开发知识库array(
  'status' => new sfWidgetFormInputCheckbox(array('value_attribute_value' => 1)),
  // various other widgets
));

Is there a way to set this checkbox to unticked from inside the form class (it's checked by default)? I can't seem to get anything to work. I found something on Google that this might be a Symfony bug that just hasn't been fixed but I'm refusing to believe it.

Setting it from the action works fine:

$this->form->setDefault('status', false);

... but I'd prefer not to have it there.


Try setting the default value at the end of the configure() method of your form, it should work :

$this->setDefault('status', false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜