On Viernes, 5 de Marzo de 2010 10:44:55 Swartz escribió:
> Thanks for the explanation Sergio.
>
> Ok, so I can't have one select form without some customization or pre-
> processing the form input.
>
> After giving it some thought I think I'll have two select boxes. One
> chooses the _type, and then the second one the _id.
> I'm trying to get it to work with update_column.
>
> So that once a _type is selected, appropriate records get loaded only
> for that type. Chaining fields essentially.
>
> I've created one helper sponsorship_type_form_column which builds the
> select box for type. But this
>
> config.columns[:sponsorship_type].options = {:update_column
> => :sponsorship_id}
>
> Does not generate any AJAX requests when something is selected
> (checking via Firebug).
You must set the onchange using javascript_for_update_column helper in your
helper override. In a later version you will get full options hash in your
helper override instead of only a name and you won't need to call the helper
by yourself.
Also, you can use form_ui select:
config.columns[:sponsorship_type].form_ui = :select
config.columns[:sponsorship_type].options = {:update_column
=> :sponsorship_id, :options => [[text1, value1], [text2, value2]]}
>
> > AS supports polymorphic associations for example in constraints (for
> > nested scaffolds). It doesn't support them in forms, they are excluded by
> > default. There is two issues with polymorphic associations:
> > - AS doesn't know from what classes include in select tag
> > - One form element is used to fill two attributes (_type and _id
> > attributes)
> >
> > You can build your own override for the column to shown Organization and
> > Individual records mixed in a select, but value cannot be the id because
> > you won't guess if that id is for an organization or individual. You will
> > have to build a value joining the class name and the id, and in
> > controller fill the association, loading the object in a before_filter or
> > overriding do_create and do_update.
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.