-
Notifications
You must be signed in to change notification settings - Fork 331
Render Field Action Flow Adding a Tab
When tabbed_by
is set in a group of columns, to render a tabbed group of columns, clicking on 'add tab' link will send a GET request to render_field
action to add the new tab, passing the group's name in the column
parameter, and also the tabbed_by
and the selected record for tabbed_by
in the value
parameter.
The following methods may be called in the following order:
-
render_field
-
add_tab
.-
process_render_field_params
, which sets different instance variables:- @source_id with the HTML's id of the changed field
- @scope with the param :scope, sent when the field triggering the request is in a subform
- @form_action, which will be :subform if @scope was sent, the param :form_action if was sent, :update if :id param was sent, or :create
- @main_columns, with the columns for the @form_action (active_scaffold_config.<@form_action>.columns)
- It sets @column with the group of columns, from the :column param.
-
updated_record_with_form
:- It will load the record being updated in the form with
find_if_allowed
if id is present, checking :read permission. -
new_model
to build a new object, to prevent saving to DB when assigning some association with the form values (e.g. has_and_belongs_to_many associations). -
copy_attributes
to copy values from the saved record into the new object, if :id param was sent. - It will set the values from constraints if controller is embedded, and set the parent association if it's nested.
-
update_record_from_params
to assign the submitted values from the form, so the object has the current state in the form when refreshing the fields.
- It will load the record being updated in the form with
-
-
Then it will render the following view and partials:
-
add_tab.js.erb
-
_form.html.erb
to render the columns for the new tab.
-
The _form
partial will render other partials depending on the columns, such as partials to render subforms, or partials for columns which have a partial form override. Check the diagram in new action in create action flow or edit action in update action flow to see what other partials or methods are used to render the columns in a form.