El Monday 26 January 2009 16:19:35 RogueBusinessServices escribió:
> Hello,
>
> I ran into some additional problems with this. Simply using select_tag
> with the ":multiple" option didn't work. In the end I got a multi-
> select list to work by creating the following helper method in my
> controller helper file:
>
> def certification_requirements_form_column(record, input_name)
> select_tag("record[certification_requirements][]",
> options_for_select(CertificationRequirement.find(:all).collect { |cr|
> [cr.name, cr.id] }, record.certification_requirements.collect { |cr|
> cr.id}), {:multiple=>true, :size=>6})
> end
>
> In this example I have a habtm relationship between the model Course
> and CertificationRequirements. I have placed this helper method in the
> helper file for Course, as CertificationRequirement is being called as
> a subform.
>
> It all seems to work now. I can save multiple
> CertificationRequirements for each Course. And when I edit my course I
> see the CertificationRequirements that I saved.
>
> The only 'strange' thing that I see is I have multiple records in my
> certification_requirements_courses join table with the same primary
> key. This doesn't appear to cause any problems because the combination
> of certification_requirement_id and course_id will always be unique.
>
> Does anyone see any potential problems with this approach however? It
> seems like the easiest way to get a multi-select box working for habtm
> associations.
You shouldn't have an id in the join table. The form helper is right.
>
> Any feedback would be greatly appreciated.
>
> Best Regards,
>
> Andrew
>
> On Jan 16, 9:53 am, RogueBusinessServices <[email protected]> wrote:
> > Thanks Sergio,
> >
> > That helps. Now I can override the entire form when it is called as a
> > subform! I will just use the code for a multi-select list box that I
> > found on the Ruby on Rails website, and substitue that into my subform
> > override.
> >
> > Thanks for your time and effort!
> >
> > Best Regards,
> >
> > Andrew
> >
> > On Jan 16, 9:19 am, "Sergio Cambra .:: entreCables - Symbol Servicios
> >
> > Informáticos S.L. ::." <[email protected]> wrote:
> > > El Friday 16 January 2009 08:52:05 RogueBusinessServices escribió:
> > > > Hello Sergio,
> > > >
> > > > Thank you very much for your reply. However what I am am looking for
> > > > is a multi-select list box. I have tried the code above, but this
> > > > gives me a bunch of checkboxes. I assume that I will have to override
> > > > thesubform, but I'm not exactly sure how I can replace only the
> > > >subformfor a particular model. I know how to override the
> > > > _form_association.rhtml, but I only want to do it in the particular
> > > > case that this form is called as asubformand for a particular model.
> > >
> > > Look at Form
> > > Overrides:http://wiki.github.com/activescaffold/active_scaffold/form-ov
> > >errides
> > >
> > > You can use ahelpermethodor partial.
> > >
> > > > Thanks,
> > > >
> > > > Andrew
> > > >
> > > > On Jan 15, 10:28 am, "Sergio Cambra .:: entreCables - Symbol
> > > > Servicios
> > > >
> > > > Informáticos S.L. ::." <[email protected]> wrote:
> > > > > El Wednesday 14 January 2009 21:34:03 RogueBusinessServices
escribió:
> > > > > > Hello,
> > > > > >
> > > > > > I've seen bits of information here and there about how to do
> > > > > > this, but it still isn't clear to me. Perhaps someone could shed
> > > > > > some light on this, or perhaps has some sample code?
> > > > > >
> > > > > > I have ahabtmrelationship between 2 models, A and B. What I want
> > > > > > is that when I edit a record of type 'A', that I see a form
> > > > > > element that is a list box and it is filled with all of the
> > > > > > records of type 'B'. All of the instances of 'B' that have an
> > > > > > association with 'A' would be selected by default. I would then
> > > > > > want to select or de-select items in that list, and then click on
> > > > > > update. When I click on update thehabtm associations would be
> > > > > > updated in the database.
> > > > > >
> > > > > > I have found some information on the RoR website about creating
> > > > > > my own partial for something like this. Is this what I would need
> > > > > > to do for ActiveScaffold? Do I need to create my own partial that
> > > > > > overrides the default one for this view? If I do that, where
> > > > > > would I need to put this file and what do I need to name it?
> > > > > >
> > > > > > I also read that when subforms are used that the params[:record]
> > > > > > namespace is different. Are there any 'gotchas' that I need to
> > > > > > look out for when doing this?
> > > > > >
> > > > > > Any help would be greatly appreciated!!
> > > > >
> > > > > class AesController
> > > > > active_scaffold do |config|
> > > > > config.columns[:b].form_ui = :select
> > > > > end
> > > > > end
> > > > >
> > > > > --
> > > > > Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L.
> > > > > ::. Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > > > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
> > >
> > > --
> > > Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
> > > Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
>
>
--
Sergio Cambra .:: entreCables S.L. ::.
Nicolás Guillén 6, locales 2 y 3. 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
-~----------~----~----~----~------~----~------~--~---