Hello,
So I want to show/hide the form fields dynamically in the controller
dependent to the action....
You are right :
your form will contains every fields : widgets and validators. Your
validator schema is simple and have strict rules for login and password.
Others are facultative.
So, set your two fields as required, leave the others as "free".
And create two templates :
One for registering, with show/hide
One other for profile, without show/hide
You can separate the two logical with isNew() method. isNew = insert =create
= registering // not isNew = update = edit = profile
About show/hide, you must consider the forms in two separate scopes :
1 - defining fields and rules on them to allow only some kind of values
: widgetSchema & validatorSchema
2 - displaying fields... This is not form but templating !
Have fun,
Alexandre
2009/10/19 mintao <[email protected]>
>
> Imagine this scenario (I think that's pretty common, so I don't
> understand why I can't find any solution):
>
> 1. For the subscription process I only have 2 mandatory fields
> "username" and "email". The password is created automatically.
>
> 2. Later, when the user is subscribed, he/she has the possibility to
> complete his/her profile with additional information like first name,
> last name, skype, etc.
>
> 3. For the login process I just need the username and password field
> to be displayed.
>
> So I want to show/hide the form fields dynamically in the controller
> dependent to the action. So I only need to know how to access the
> fields of an embedded form (which contains additional information to
> sfUserGuard).
>
> Best,
> Florian
>
>
> On Oct 19, 12:12 am, mintao <[email protected]> wrote:
> > if there's a field called "last_name" in the embedded form called
> > "profile", how can I access this?
> >
> > On 18 Okt., 11:15, geoffroy <[email protected]> wrote:
> >
> > > Hie,
> >
> > > I think you have ti unset() fields like :
> >
> > > class signForm extends PluginsfGuardUserForm
> > > {
> > > public function configure()
> > > {
> > > $form = new sfGuardUserProfileForm();
> > > $this->embedForm('profile', $form);
> >
> > > unset(
> > > $this['filed_u_dont_want1],
> > > $this['filed_u_dont_want2'],
> > > );
> > > }
> >
> > > }
> >
> > > Or try to unset() fields in your sfGuardProfileForm extend class.
> >
> > > Geo
> >
> > > On Oct 17, 11:35 pm, mintao <[email protected]> wrote:
> >
> > > > Hi folks,
> >
> > > > it's really no fun for a newbie to configure the symfony forms. I'm
> > > > using 1.3Alpha2 and activated the plugin sfDoctrineUserGuard. The
> > > > description of this plugin is so old that nearly nothing of the
> > > > described steps worked.
> > > > So 3 days later I'm trying to set up a sign up form. Therefore I use
> > > > the sfGuardUserForm and an embedded ProfileForm:
> >
> > > > class signForm extends PluginsfGuardUserForm
> > > > {
> > > > public function configure()
> > > > {
> > > > $form = new sfGuardUserProfileForm();
> > > > $this->embedForm('profile', $form);
> > > > $this->useFields(array(
> > > > 'username',
> > > > 'profile.email',
> > > > ));
> > > > }
> >
> > > > }
> >
> > > > As you can imagine, I try only to display a username and an email
> > > > field. The username is part of the plugin, the email is part of the
> > > > embedded form.
> >
> > > > My question: my version doesn't work. How can I display fields of
> > > > embedded forms?
> >
> >
> >
>
--
Alexandre Salomé -- [email protected]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---