You MUSTdestroy that widget/validator because there is possiblity that
DoctrineForm will hydrate (@see doUpdateObject() method) your object with
VALIDATED hidden input.



2010/12/26 dmitrypol <dmitry...@gmail.com>

> Thank you VERY MUCH.  I was not able to make unset work as I think it
> needed the id but you gave me a great idea.  I went with this approach
> and using sfWidgetFormInputHidden
>
> if($this->getObject()->isNew())
> {
> $this->setWidgets(array(
> ...
> 'pref_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this-
> >getRelatedModelName('pref'), 'add_empty' => false)),
> ...
> }
> else
> {
> $this->setWidgets(array(
> ...
> 'pref_id'  => new sfWidgetFormInputHidden(),
> ...
> }
>
> Your comment about security got me thinking.  Does anyone have
> experience securing sfWidgetFormInputHidden?
>
> Dmitry
>
>
> On Dec 25, 3:50 pm, Alan Bem <alan....@gmail.com> wrote:
> > If you want to hide any widget, don't outputing them is not a good
> (secure)
> > choice. Here's better idea:
> >
> > In configure() method of your form put
> >
> > if($this->getObject()->isNew()) {
> >     $this->widgetSchema['preference_id'] = //etc
> >     $this->validatorSchema['preference_id'] = //etc
> >
> > }
> >
> > or in case preference_id is already set
> >
> > if(!$this->getObject()->isNew()) {
> >     unset($this['preference_id']);
> >
> > }
> >
> > In templates this should work
> >
> > if(isset($form['preference_id'])) {
> >     // output widget
> >
> > }
> >
> > This method is also "echo $form" friendly.
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to