[symfony-users] Re: Different validation for update/insert

2009-09-23 Thread zeek


The Symfony form framework is maybe too complicated (Symfony is now an
MVCF architecture), but if you are going to use it at all, you have to
stick with one form class for each model. You are inviting a lot of
pain if you start using multiple form classes.


On Sep 23, 6:16 am, Simone Fumagalli 
wrote:
> Hello.
>
> I need two different validations for my form.
>
> The scenario is quite easy.
>
> 1) The user subscribe to the site by providing few fields (name and
> email), others data are optionals.
> 2) The user get an email with an invitation to complete his data, in
> this case almost all the fields are mandatory
>
> How can I achieve this ? I thought about create 2 different form class
> with e different validatorSchema
>
> class UserInsertForm extends BaseCandidateForm {}
> class UserUpdateForm extends BaseCandidateForm {}
>
> so to use the first one for the insert and the second for the update
> action.
>
> Am I on the right way ? Or am I missing something and there is a
> smarter way ?
>
> Ciao
>
> --
> Simone
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[symfony-users] Re: Different validation for update/insert

2009-09-23 Thread Richtermeister

Hey Simone,

I would use the same form, but in the configure function you do
something like:

if($this -> isNew())
{
  //add or configure validators for create
}
else
{
  //add or configure validators for update
}


clean and easy to maintain.

Daniel



On Sep 23, 3:16 am, Simone Fumagalli 
wrote:
> Hello.
>
> I need two different validations for my form.
>
> The scenario is quite easy.
>
> 1) The user subscribe to the site by providing few fields (name and
> email), others data are optionals.
> 2) The user get an email with an invitation to complete his data, in
> this case almost all the fields are mandatory
>
> How can I achieve this ? I thought about create 2 different form class
> with e different validatorSchema
>
> class UserInsertForm extends BaseCandidateForm {}
> class UserUpdateForm extends BaseCandidateForm {}
>
> so to use the first one for the insert and the second for the update
> action.
>
> Am I on the right way ? Or am I missing something and there is a
> smarter way ?
>
> Ciao
>
> --
> Simone
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---