On Mar 10, 12:58 pm, HAUSa
<jeroen_heeft_behoefte_aan_r...@hotmail.com> wrote:
> I got a form, in which users can select multiple values for a field
> using sfWidgetFormChoiceMany().
>
> Now, is it possible to add more values to the submitted array on
> submit? I'm not talking about default values when the form shows, but
> specifically when the form gets submitted. So the default values are
> added afterwards.

If I understand you, then easy enough. In your actions.class.php file,
just alter your executeUpdate method.

I needed to add a date that was one day in the future,as a default
value, so I did this:

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new NewNewsForm(NewNewsPeer::retrieveByPk($request-
>getParameter('id')));

    $submittedValuesArray = $request->getParameter('new_news');
    /*
    * 03-09-09 - if I do this:
        *     print_r($submittedValuesArray);
        *     die(" stopped execution ");
        *
        * I get an array like this:
        *
        *     Array ( [title] => Sagisaws beat the Apaches [description] =>
        *        A hard fought game, yesterday, down in Del Ray.
        *      [active] => 1 [id] => )
        *
    */

        if ($submittedValuesArray["id"] == "") $submittedValuesArray["date"]
= date("Y-m-d h:m:i", time() + 86400);

    $this->form->bind($submittedValuesArray);
    if ($this->form->isValid())
    {
      $new_news = $this->form->save();

      $this->redirect('newnews/edit?id='.$new_news->getId());
    }

    $this->setTemplate('edit');
  }

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