Hi everyone. I would like to know about how could i set default values
in Forms with more than simple InputText fields.

I have this on my BooksForm.class:

$this->setDefaults(array(
         'proveedor_list'  => $per,      /* Belogns to m2m relation*/
         'procedencia'      => $proc,   /*Blegons to simple InputText
         'estante_list'       => $st,       /* Belongs to  1:n
relation*/
         ...
         ...
         ...
       ));

So, InputText is set without any problem, but estante_list and
proveedor_list aren't.

For this i used the follow:

if ($st != ''){
          $this->widgetSchema['estante_list'] = new
sfWidgetFormInputText();
          $this->validatorSchema['estante_list'] = new
sfValidatorString(array('max_length' => 255));
      }else{
          $this->widgetSchema[estante_list'] = new
sfWidgetFormDoctrineChoice(array(
          'expanded' => false, 'model' => 'Proveedor', 'add_empty' =>
true
          ));
          $this->validatorSchema['estante_list'] = new
sfValidatorDoctrineChoice(array(
          'multiple' => true, 'model' => 'Proveedor', 'required' =>
false
          ));
      }

Well, if $st has any data i change the widget from DoctrineChoice to
InputText, and this works, if $st hasn't any data i just set the
default widget.

For this. estante_list that belongs to 1:n relation works right, in my
form i got an InputText field with $st value.

BUT, for proveedor_list doesn't work. I got an InputText Field with no
data in It, just ARRAY word. So i'm not enough sure if this is the
best way.

I feel that  must exist another way to set values to DoctrineChoice
type fields.

If you are asking yoursalef why i want to set these default values to
those DoctrineChoice collections, it's because the defualt values were
chose by users before to the present Form

I hope someone can help me.

Thank's a lot for your time.

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@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