Hey Ca-Phun,

glad to hear all is good. I also thought I lost some "elegance" in the
process, but only until I started to look at the generator.yml as a
quick&dirty helper, and the form as the refinement tool. Now life is
much nicer ;)

Also, just to add some more info to your solution, the add_empty
option only seems supported in the sfWidgetFormPropelChoice class, not
in the regular sfWidgetFormChoice. In the later version you have to
include the empty option as part of your choices array, and at first I
found it somewhat tricky to add a truly empty element to an array
(without creating a 0 key for it). The solution was
$choices_with_empty = array("" => "") + $choices;

Never used the + operator for arrays before, but this is where it
comes in handy.

Hope is helps someone,
Daniel



On Aug 12, 10:10 am, Ca-Phun Ung <cap...@yelotofu.com> wrote:
> Hey Daniel,
>
> Thanks that worked! Not as elegant but I agree it's more appropriate in the
> Form class.
>
> For the benefit of others this is what I ended adding to my Form class:
>
> $this->widgetSchema['author_id']  = new sfWidgetFormPropelChoice(array(
>   'model'     => 'Author',
>   'add_empty' => 'Default Unknown'
> ));
>
>
>
> On Wed, Aug 12, 2009 at 11:43 PM, Richtermeister <nex...@gmail.com> wrote:
>
> > Hey Caphun,
>
> > I believe the place to handle this stuff is in the form classes now,
> > and I find that a better place as well, since it affects all instances
> > of a form and you can adjust the validator at the same time as well
> > (assuming you need to tell it to allow an empty submission or not..).
>
> > Hope this helps,
> > Daniel
>
> > On Aug 12, 8:35 am, Ca-Phun Ung <cap...@yelotofu.com> wrote:
> > > On Wed, Aug 12, 2009 at 11:00 PM, Eno <symb...@gmail.com> wrote:
>
> > > > If you look at the code, you'll see its still there in 1.1 and 1.2.
>
> > > Hmm, but params: include_custom='Choose an option', doesn't work in 1.2.
>
> > > Given the above the first option in my drop down should be:
>
> > > <option value="">Choose an option</option>
>
> > > But instead it remains as
>
> > > <ption value=""></option>
>
> > > Sorry if there's something obvious I'm missing.
>
> > > > What's the difference between using include_custom and just using
> > label: ?
>
> > > Label is the text label of the form field and include_custom is the text
> > of
> > > the first option in a drop down list.
>
> --
> Ca-Phun Ung
> +http://yelotofu.com
> + hongkong, zce, jquery, jqueryui, php, css, html
--~--~---------~--~----~------------~-------~--~----~
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