It can't work that way. When a user submit a form, it only submits 1 
form, not both. So, you need a way to determine which one has been 
posted and then only bind this one.

Fabien

--
Fabien Potencier
Sensio CEO - symfony lead developer
sensiolabs.com | symfony-project.com | aide-de-camp.org
Tél: +33 1 40 99 80 80


sh1ny wrote:
> Hello. I've run into some oddness ( or it's probably just me, doing
> things wrong ), but i need a little advice on multiple forms with
> 1.1 . The basic setup is 2 forms for user profile, in ajax tabs ( yui
> tabs to be exact ). One form is for password change/email change, the
> other form is profile - names, country, age etc. Everything worked
> fine, untill i added this to the password form :
> 
>     public function configure ()
>     {
>         $this->validatorSchema->setPostValidator(new
> sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL,
> 'password_repeat'));
>     }
> 
> 
> to the password/email form.
> The both use the same action and view to get rendered. The action
> looks like this :
> 
>             $user = Doctrine::getTable('sfGuardUser')->find($this-
>> getUser()->getGuardUser()->id);
>             $this->form = new sfGuardUseProfileEditForm($user);
>             $this->profileform = new sfGuardUserProfileForm($user-
>> profile);
>             if ($request->isMethod('post')) {
>                 $this->form->bind($this-
>> getRequestParameter('sf_guard_user'));
>                 if ($this->form->isValid()) {
>                     $this->forward404Unless($this->form->save());
>                 }
>                 $this->profileform->bind($this-
>> getRequestParameter('sf_guard_user_profile'));
>                 if ($this->profileform->isValid()) {
>                     $this->forward404Unless($this->profileform-
>> save());
>                 }
>             }
> 
> and the view looks like this :
> 
> <?php use_helper('YUITabview'); ?>
> 
>    <?php yui_tabview_start('demo') ?>
>    <div id="demo" class="yui-navset">
>      <ul class="yui-nav">
>        <li class="selected"><a href="#tab1"><em>Edit Password/Email</
> em></a></li>
>        <li><a href="#tab2"><em>Edit Profile</em></a></li>
>        <li><a href="#tab3"><em>Edit Avatar</em></a></li>
>      </ul>
>      <div class="yui-content">
>        <div><p>
> <?php if(!$sf_user->isAnonymous()): ?>
> <form action="<?= url_for('user/index') ?>" method="POST">
> <table>
> <?php echo $form; ?>
> </table>
> <input type="submit" value="Submit" />
> </form>
> <?php endif; ?>
> </p></div>
>        <div><p>
> <?php if(!$sf_user->isAnonymous()): ?>
> <form action="<?= url_for('user/index') ?>" method="POST">
> <table>
> <?php echo $profileform; ?>
> </table>
> <input type="submit" value="Submit" />
> </form>
> <?php endif; ?>
> </p></div>
>        <div><p>To be done</p></div>
>      </div>
>    </div>
> <?php yui_tabview_end('demo') ?>
> 
> Everything works fine without the postvalidator, for comparing the
> inputted passwords, but with it, whenever you submit any of the forms,
> the other one throws errors for all the required fields, complaining
> that those fields are required. If still saves the data properly, just
> the other form is basicly throwing out errors, when it shouldnt be.
> 
> Any advices on how i can handle this ? I could just separate the forms
> in different actions, but i think that's not the point. Again,
> everything works as expected without the postvalidator.
> > 
> 


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

Reply via email to