Add new standard support for subforms on pages.
Review Request #10950 — Created March 12, 2020 and submitted — Latest diff uploaded
We have a number of pages in the administration UI today that make use
of subforms, which are forms dynamically hidden or shown based on
the selection on another form control. Each one of these had to be
written manually, which made implementations inconsistent and sometimes
buggy.This change introduces a new formal subform implementation, which we'll
be able to start using in the settings pages. There are several new
things introduced here:
An
-is-subform
modifier onrb-c-form-fieldset
, which turns a
fieldset into a subform.Data attributes for specifying a subform group, ID, and a controller
element ID (which is used to automatically manage subform displays).Guidance on setting both the
disabled
andhidden
attributes to
ensure the form's data won't be validated or sent to the server, and
hiding the form from display and from screen readers (note that
hidden
is an HTML 5.1 attribute, which is available in all our
supported browsers, including IE11).Support in
RB.FormView
for automatically setting up and managing
subform state based on the data attributes.Standard templates for representing a form instance as a subform,
and a dictionary of subform IDs to forms as subforms.Upcoming changes will update other forms to use this, fixing our form
validation issues on Django 1.11.
Unit tests pass.
Made use of this to update all the existing subforms (which will be
in an upcoming change). Verified everything worked as expected.