This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Chaining Form Fields
Sometimes you want update a form field after set a value in other field, for example, you have a form with a dropdown to select an author and another dropdown to select a book, and you want select books from the chosen author. So you need to render the books dropdown each time an author is chosen.
class UsersController < ApplicationController
active_scaffold do |config|
config.columns[:author].form_ui = :select
config.columns[:author].options = {:update_column => :book} # enables the "magic"
config.columns[:book].form_ui = :select
end
end
class UsersHelper
def options_for_association_conditions(association)
if association.name == :book
{'books.author_id' => @record.author_id}
else
super
end
end
end
The helper code is to show only books belonging to chosen author, like is explained in Custom Association Options.
It doesn’t work only with association columns, it work with simple columns too, and with your form overrides






