Hello,
I been trying all day to do multiple insert for the same form based on
a number and i couldn't go any where with it. I hope someone here
would be help me out...

am using admin generator on 1.4 doctrine. I have a form which i
generated with only two fields. what am trying to do is, based on a
number inserted the form will be repeated x number of times.

In the generator file I added a partial which placed a text field in
the beginning of the form with default value of 1. If I choose 2 the
form below gets duplicated twice..

Here is what i did to my form.. In action

class prizesActions extends autoPrizesActions
{
  public function executeNew(sfWebRequest $request)
  {

    $this->form = $this->configuration->getForm(null, array('n' =>
5));
    $this->prizes = $this->form->getObject();

  }
}



and in the PrizesForm, I wrote the following

class PrizesForm extends BasePrizesForm
{
 public function configure()
  {
        $array = $this->getOptions();
        for ($i = 0; $i < $array['n']; $i++) {

            $this->setWidgets(array(
              'id'         => new sfWidgetFormInputHidden(),
              'prize_no'   => new sfWidgetFormInputText(),
              'prize'      => new sfWidgetFormInputText(),
              'created_at' => new sfWidgetFormDateTime(),
              'updated_at' => new sfWidgetFormDateTime(),
            ));

            $this->setValidators(array(
              'id'         => new sfValidatorDoctrineChoice(array('model' =>
$this->getModelName(), 'column' => 'id', 'required' => false)),
              'prize_no'   => new sfValidatorInteger(array('required' =>
false)),
              'prize'      => new sfValidatorString(array('max_length' =>
200, 'required' => false)),
              'created_at' => new sfValidatorDateTime(),
              'updated_at' => new sfValidatorDateTime(),
            ));

            $this->widgetSchema->setNameFormat('prizes['.$i.'][%s]');

            $this->errorSchema = new sfValidatorErrorSchema($this-
>validatorSchema);
        }





        unset(  $this['updated_at'],
                        $this['created_at']
                        );
  }
}




I think the loop is working but its over writing the widgets at every
entry and i cannot find other method to append instead. Any ideas?


Thanks,

-- 
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