开发者

Adding a form field that is not in the schema to Doctrine form Symfony 1.4

I have an image upload form and at the bottom, I'd like to have a checkbox that the user must check before 开发者_JS百科submitting the form, certifying that they have the right to distribute the photo. I've tried adding it as a Widget in the Form class, but it is not displaying. What is the best way to accomplish this?


For validation, you can add this to your form class to allow fields outside the model:

$this->validatorSchema->setOption('allow_extra_fields', true);
$this->validatorSchema->setOption('filter_extra_fields', false); // true or false

Other than that, just adding the widget in the standard way should work fine.


Adding a new widget to your form should be the right way.

class ImageForm extends BaseImageForm
{
  public function configure()
  {

    $this->widgetSchema['copyright'] = new sfWidgetFormInputCheckbox();
  }
}

For conditional validation, check this cookbook page should still be valid.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜