Good question, I was sure someone would ask me that :-]
As I said in my example, I have a form that is instantiated in several
pages. This forms has a field 'updated_by' that contains the ID of
current user (according to session data)

So, it's better - I think - to write only one time "setDefault
('updated_by', 'value');" within the form instead of writing it each
time you instantiate a new form. (and the developper may forget to set
the value...).

I think this is a good reason, at least, there should be a way to do
it...

--
Adrien Mogenet
http://adrien.frenchcomp.net/blog

On 22 avr, 19:48, Lawrence Krubner <[email protected]> wrote:
> On Apr 22, 7:36 am, Adrien Mogenet <[email protected]> wrote:
>
> > Be careful Mark, I think that by this way you'll get the same issue
> > that I got...
>
> > =>http://groups.google.fr/group/symfony-users/browse_thread/thread/8473...
>
> > setDefault() didn't work for me within the form to "force" a value got
> > from session ; but it worked when I call this method from the action
> > class.
>
> > I'm still looking for a way to force this setting within the form..
>
> I'm just asking out of pure curiosity, but what advantage do you get
> from setting this value in the form, rather than the action?
>
> > On 22 avr, 12:34, Mark Smith <[email protected]> wrote:
>
> > > I have a form with a list of services on it. When the user submits the
> > > form, I want it to remember what item on the list was selected. Even
> > > if it's several page requests later.
>
> > > I'm storing the index in session and trying to apply it to the form
> > > field. Sending it in the constructor is probably tidier anyway, so I'm
> > > changing it to do that.
>
> > > But for future reference, you are saying $form->setDefault('field',
> > > 'value'); will work even after it's constructed and configure() has
> > > been called?
>
> > > On Apr 22, 10:38 am, Bernhard Schussek <[email protected]> wrote:
>
> > > > Hi Mark,
>
> > > > On Wed, Apr 22, 2009 at 10:23 AM, Mark Smith
>
> > > > <[email protected]> wrote:
> > > > > So you are saying the only way to change a form field once the object
> > > > > exists, is to completely rebuild the form?
>
> > > > No. The question is _when_ you want to change the form. You can change
> > > > the default values any time in the object lifecycle before you render
> > > > the form. Note that the default values are not displayed anymore once
> > > > you call ->bind().
>
> > > > If you need more help, please provide a little more information on
> > > > what you are trying to achieve. Otherwise it's hard to give you
> > > > specific advice.
>
> > > > Bernhard
--~--~---------~--~----~------------~-------~--~----~
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