Chosen and Add new

16 views
Skip to first unread message

Gloufy

unread,
Aug 25, 2025, 4:19:22 PM8/25/25
to ActiveScaffold : Ruby on Rails Gem
Hi Sergio

Do you think it's possible to use form_ui :chosen and :add_new ?

Thanks for your response 

Gloufy

Sergio Cambra

unread,
Aug 26, 2025, 10:41:58 AM8/26/25
to ActiveScaffold : Ruby on Rails Gem
It should be posible yo add support for it

--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activescaffol...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/activescaffold/73cbd7c1-1764-45ab-8d2d-529beb84207cn%40googlegroups.com.

Sergio Cambra

unread,
Aug 26, 2025, 1:12:50 PM8/26/25
to ActiveScaffold : Ruby on Rails Gem
I have just added support for :add_new with singular associations in :chosen,
but I couldn't test it. I hope it works as in other form_ui, please test it
and report any issue.

Regards,
Sergio

El martes, 26 de agosto de 2025 16:41:39 (hora de verano de Europa central),
Sergio Cambra escribió:
> > <https://groups.google.com/d/msgid/activescaffold/73cbd7c1-1764-45ab-8d2d
> > -529beb84207cn%40googlegroups.com?utm_medium=email&utm_source=footer> .




Gloufy

unread,
Jan 1, 2026, 11:40:13 AMJan 1
to ActiveScaffold : Ruby on Rails Gem
hello Sergio !!! happy new year !! do you know how add new when multiple associations ? in fact I just wand add record without refresh the page (when I create it in a another page)

Sergio Cambra

unread,
Jan 20, 2026, 4:38:10 PM (12 days ago) Jan 20
to actives...@googlegroups.com
Hi Gloufy

I have tested chosen with add_new, in a belongs_to association, and I had to fixed it. It's in master branch, which I expect to release as 4.2.0 soon.

However, using add_new with has_many association is not supported, either using :select or :chosen.

The belongs_to or has_one associations support getting an ID to associate with an existing record, or a hash with fields from subform, saving a new record. So add_new just had to change between one UI or another, and the existing code saving the params would work.

However, a has_many association expects an array of IDs, or an array of hashes. I don't think the code that parses the params to save the form would work with a mixed arrays of IDs and hashes. The easier way to support this would be adding a link to open a new tab or jQuery dialog, with the form to create a record, and then use JS to add the new record into the available choices (checkbox or option in a select). But there is no support for that yet.

Regards,
Sergio

Sergio Cambra

unread,
Jan 21, 2026, 7:22:51 AM (11 days ago) Jan 21
to actives...@googlegroups.com
I just remembered that AS has a popup mode for add_new, which worked exactly as I described, so I have added support for add_new with popup mode in multiple associations.

You can use form_ui = :chosen, {add_new: {mode: :popup}}, or you can use the short syntax, form_ui = :chosen, {add_new: true}, which will default to popup mode for multiple associations.

It's supported for :select and :record_select on multiple associations too, for any of the :select versions on collection associations (checkboxes, draggable lists or select tag with multiple attribute).

Regards,
Sergio
Reply all
Reply to author
Forward
0 new messages