Re: [symfony-users] How to get array of field names and default values by inspecting $form

2010-04-28 Thread Gareth McCumskey
getWidgetSchema()->getFields() as
$widget_name=>$widget_element): ?>

On Mon, Apr 26, 2010 at 9:22 PM, notbrain  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 at
> http://groups.google.com/group/symfony-users?hl=en
>



-- 
Gareth McCumskey
http://garethmccumskey.blogspot.com
twitter: @garethmcc

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


Re: [symfony-users] How to get array of field names and default values by inspecting $form

2010-04-27 Thread Thomas Rabaix
foreach($schema->getDefaults() as *$field_name* => $default) {
  print $default . "\n";
}

?

On Mon, Apr 26, 2010 at 9:22 PM, notbrain  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 at
> http://groups.google.com/group/symfony-users?hl=en
>



-- 
Thomas Rabaix
http://rabaix.net

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


[symfony-users] How to get array of field names and default values by inspecting $form

2010-04-27 Thread notbrain
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 at
http://groups.google.com/group/symfony-users?hl=en