Look at 
http://groups.google.com/group/symfony-devs/browse_thread/thread/4c81264521f8bc60

On Feb 24, 2:20 pm, Tomasz Ignatiuk <tomek.ignat...@gmail.com> wrote:
> On 16 Sty, 13:35, Thomas Dedericks <tho...@tequila-studio.com> wrote:
>
>
>
> > Hi,
>
> > Not tested:
>
> > public function configure() {
>
> >         ...
>
> >         # add * torequiredfields' labels:
> >         foreach ($this->widgetSchema as $name => $widget)
> >         {
> >                 if (isset($this->validatorSchema[$name]) && 
> > $this->validatorSchema[$name]->hasOption('required') && 
> > $this->validatorSchema[$name]->getOption('required') == true)
> >                 {
> >                         $label = ($widget->getLabel() != null) ? 
> > $widget->getLabel() : $name;
> >                         $widget->setLabel($label.' *');
> >                 }
> >         }
>
> > }
>
> > Thomas Dedericks
>
> Unfortunatelly it doesn't work. But if you do some stuff before and
> with little change...it works :)
> 1. Required option is true as default. I don't know why it isn't set
> in widgetSchema. So this won't work: 
> $this->validatorSchema[$name]->hasOption('required') && 
> $this->validatorSchema[$name]->getOption
>
> ('required') == true
> 2. If label is set in generator.yml, it isn't  set in widgetSchema, so
> $widget->getLabel() != null is always null You have to set it manually
> in configure()
> 3. widgetSchema i a set of objects, not name fields, so you have to
> add this:   foreach ($this->widgetSchema->getFields() as $name =>
> $widget)
>
> So you have to set labels for requried fields in configure() of a form
> and for some fields, like boolean you have to add manually required to
> true, like this: $this->validatorSchema['master'] = new
> sfValidatorBoolean(array('required' => true)); And also change this:
> && $this->validatorSchema[$name]->getOption('required') != false).....
> required != false
>
>     foreach ($this->widgetSchema->getFields() as $name => $widget)
>     {
>       if (isset($this->validatorSchema[$name]) && 
> $this->validatorSchema[$name]->hasOption('required') && $this-
> >validatorSchema[$name]->getOption('required') != false)
>
>       {
>         $label = ($widget->getLabel() != null) ? $widget->getLabel() :
> $name;
>         $widget->setLabel($label.' *');
>       }
>     }
>
> All in all it is faster just to add * manually for required fields:
>     $this->widgetSchema->setLabels(array(
>         'logo' => 'Logo *',
>         'name' => 'Name *',
>         'master' => 'Master *',
>     ));
--~--~---------~--~----~------------~-------~--~----~
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