-
Notifications
You must be signed in to change notification settings - Fork 330
Update Action Flow
These methods are called in the following order:
-
update_authorized_filter
called as before_action-
update_authorized?
(or the method defined in conf.update.link.security_method if it's changed) is called to check the permission. If this method returns false,update_authorized_filter
will raise ActiveScaffold::ActionNotAllowed.
-
-
edit
-
do_edit
which usesfind_if_allowed
to load the record to be edited, checking :update permission. -
respond_to_action
, which will call the corresponding response method for new action and the requested format
-
do_edit
can be overrided, for example to change some attributes.
Then it will render these views:
- update.html.erb (only for HTML request)
- _update_form.html.erb
- _base_form.html.erb
- _form_messages.html.erb
- _messages.html.erb (only for HTML request)
- _form.html.erb
- footer_extension partial if _base_form was called with this variable
- _form_messages.html.erb
- _base_form.html.erb
- _update_form.html.erb
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.
The _update_form
partial can be overrided and call render :super with local variables, to change some of default behaviour of _base_form:
- xhr: to force rendering as XHR request or HTML request instead of relying on the value of request.xhr?
- form_action: to use other action in the controller instead of
update
. - method: to use other HTTP method instead of PATCH.
- cancel_link: use false to avoid adding a cancel link to the form.
- headline: to change the header of the form.
The _base_form
partial can be overrided to render :super setting some variables to change the default behaviour, although it's used by many actions. Also, _create_form
partial can be overrided copying the code, and passing more variables to _base_form
. The following variables can be used, besides the ones explained above:
- multipart: to enable or disable rendering the form as multipart instead of relying in
active_scaffold_config.update.multipart
. - persistent: can be
:optional
,true
orfalse
, instead of relying inactive_scaffold_config.update.persistent
. - columns: an ActionColumns instance to use instead of
active_scaffold_config.update.columns
, build it withactive_scaffold_config.build_action_columns :update, [<list of columns>]
. - footer_extension: to render a partial after footer buttons, inside the p tag with class form-footer.
- url_options: to change URL to submit the form, instead of default
params_for(action: :update)
. - scope: to render the fields with an initial scope.
- floating_footer: to enable or disable the floating footer when form is too big to fit in the window, instead of relying on
active_scaffold_config.update.floating_footer
. - submit_text: the text of submit button, which defaults to the value of
form_action
(update with default form_action). - apply_text: the text of submit button which doesn't close the form, when persistent is enabled. The default value is
#{form_action}_apply
(update_apply with default form_action). - body_partial: to use a different partial to render the fields in the form, instead of default
_form
partial.