Thanks, this is what I was trying to do, but actually it is not very nice :). It didn't occur to me I could pass a parameter in the constructor.
Paolo On Sep 8, 4:43 pm, Christopher Schnell <[email protected]> wrote: > hi, > > you could do something nasty like > > if(!$this->getUser()->hasAttribute('user')) > $tempSchema=$this->form->getWidgetSchema(); > unset($tempSchema ['mine']; > $this->form->setWidgetSchema($tempSchema); > > } > > but this wouldn't be testable. > > better solution > ishttp://eatmymonkeydust.com/2009/08/symfony-forms-flexible-widgets-bas... > > Regards, > Christopher. > > > -----Ursprüngliche Nachricht----- > > Von: [email protected] [mailto:symfony- > > [email protected]] Im Auftrag von torok84 > > Gesendet: Mittwoch, 8. September 2010 16:32 > > An: symfony users > > Betreff: [symfony-users] Removing a field from a form in an action > > > Hi, > > > I have a form to select some search options. I have a field that I > > wanto to show only if the user is logged in. I want to do something > > like this: > > > if(!$this->getUser()->hasAttribute('user')) > > unset($this->form->widgetSchema['mine']); > > > that doesn't work because widgetSchema is protected. Moreover doing > > this would leave a dangling validator for the 'mine' field. I > > undestand I can create a second form class without the 'mine' field, > > but it would be nice if I could simply unset a field. > > > Thanks > > Paolo > > > -- > > 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 [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
