Problem/Motivation
Improve documentation and test coverage.
Steps to reproduce
Proposed resolution
- Add a kernel test
CssGeneratorTestwhich tests behaviour of theadvancedform.cssgeneratorservice with various inputs & expected outputs - Add a
CssGeneratorInterfaceand allow the service to throw an exception if the rules input is invalid? - #3387723: selected-xxx classes not removed on select updates
Add FunctionalJavascript test to ensure that classes are correctly added/removed from node form when terms are selected/deselected - Document steps to set up a content type, term and complex field so that behaviour is documented
- Document syntax for CSS rules
Remaining tasks
User interface changes
- Improve documentation of rules syntax
- Improve documentation of how to use
API changes
- Interface for CSS generator
Data model changes
Issue fork advancedform-3387680
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xurizaemonSteps to configure term-based behaviour
Comment #4
xurizaemonAdding related issue #3387723: selected-xxx classes not removed on select updates where test coverage for fields hidden by select option conditions is added.
Comment #5
xurizaemonComment #6
xurizaemonWhat threw me about this was that the rules syntax seems to ask you to incorporate a space, OR to add an additional selector inside the square brackets.
Actual usage "in the wild" appears to be like this (now "documented" in the test coverage):
This will generate:
form.advanced-form-filtered.node-page-form.selected-standard-page .field--name-field-intro { display: none; }Which works because
.selected-standard-pageis applied to the create/edit form when term "Standard Page" is selected in a term<select>.Without the class inside the square brackets, I found I had to include an additional space to make the selectors work, and that felt unintuitive.
Honestly the whole "rules to CSS" thing feels unintuitive and I'd probably use SASS today and keep the JS, but that's another issue.