Have you tried ->getDefaults() on the form?

On Apr 26, 9:22 pm, notbrain <notbr...@gmail.com> wrote:
> I've been looking through the docs and API for methods that would
> allow me to do this, but I find myself running around in circles and
> getting a little frustrated by lack of examples/clarity. What I need
> to get is an array of field_name/default_value pairs as set up in the
> form class. Let's say my form has two fields, name and email, and
> their default values are "Full name" and "n...@example.com". The array
> I'm looking to get is
>
> SETUP
> --------------------------------
> ...
> $this->setWidgets(array(
>       'name' => new sfWidgetFormInputText(array('default' => 'First
> name')),
>       'email' => new sfWidgetFormInputText(array('default' =>
> 'n...@example.com')),
> ));
> ...
> ================
>
> DESIRED ARRAY
> --------------------------------
> Array
> (
>     [name] => "Full name"
>     [email] => "n...@example.com"
> )
>
> I can get an array of names and default values separately (https://
> gist.github.com/5cdd2009a8a7b85cfdae), but was curious about the best
> way to construct this--hopefully with a single loop construct on the
> $form object.
>
> Thanks!
> Brian
>
> --
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
>
> 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 
> athttp://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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