Problem/Motivation
farmOS provides a framework for developers to build "Quick Forms" which are simplified data entry forms that are targeted at specific use-cases or workflows. Examples of these include the Planting quick form, the Birth quick form, and the Movement quick form. Documentation for quick form development is available at: https://farmos.org/development/module/quick/
In the current implementation, there is no standardized way for quick form developers to provide configuration options that affect the display and behavior of their quick forms.
Proposed resolution
This work will extend farmOS's Quick Forms framework to make it possible for developers to build "Configurable quick forms" in a standardized way. "Configurable quick forms" are quick forms that will have their own configuration options that can be adjusted by the farmOS user to change how the quick form itself works/behaves.
Developers will be able to designate individual quick forms as "configurable", and provide a separate "configuration form" for them, which saves to a new configuration entity type.
A bonus outcome of this work will be that it becomes possible for multiple instances of the same quick form plugin to be created. Each configuration entity will produce one quick form (each with unique configuration), and multiple configuration entities may use the same quick form plugin.
Remaining tasks
Provide a configuration entity type for quick form instances.Provide aConfigurableQuickFormInterfacethat quick forms can use to declare themselves configurable.Provide aConfigurableQuickFormTraitthat quick forms can use for default methods.Provide aQuickFormInstanceManagerservice class with helper methods for instantiating quick form plugins.Allow quick forms to be disabled by disabling their config entities.Provide a "default instance" for quick forms that do not have a config entity saved (for backwards compatibility).Add arequiresEntityproperty to quick form plugins to optionally prevent creating default instances.Add aconfigure quick formspermission, granted to managed roles with "config" level access.Add aConfigureQuickFormfor building, validating, and submitting configuration forms.- Save configuration entities when
ConfigureQuickFormis submitted. Automatically build routes, menu items, and tabs to navigate to configuration forms.- Refactor route building logic into a single route.
- Provide developer documentation for building configurable quick forms.
- Automated tests.
User interface changes
This will not introduce any UI changes itself, but it will provide configuration forms for future quick forms that are designated as configurable.
API changes
Any saved quick form configuration entities will be available via API.
Data model changes
A new configuration entity for quick form configurations.
Issue fork farm-3354935
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
elberHi @m.stenta do you want something like that (https://www.drupal.org/project/bigmenu/issues/3348166) create a configuration form?
Comment #3
m.stentaOh thanks @elber but I should have mentioned that I've already started this, and I'm getting close to finishing it already. I appreciate the interest though! I'll try to post an update with more details soon...
Comment #4
elberok don't worry I can do the review when you finish if you want.
Comment #5
m.stentaUpdated the issue description to reflect the current status. @paul121 and I are working on wrapping this up currently.
I also created a change record for one internal PHP API change that is being made: https://www.drupal.org/node/3379686
Comment #6
m.stentaThe remaining tasks are:
requiresEntityattribute, and perhaps how to disable quick forms via their config entities.submitConfigurationForm()- there's a@todoin code for this. But it may also be affected by the next item...ConfigureQuickFormfromEntityFormto handle boilerplate config entity adding/updating logic.Comment #7
m.stentaHmm does this also affect menu links and tasks? Do we need to ensure those are re-generated when config entities are added/deleted?
Comment #8
m.stentaAnother question came up on the call w/ @paul121 today: What happens to quick form actions when you disable a quick form?
Comment #10
paul121 commentedThese items are done!
The task links are refactored similar to the routes so there are only 2 task link definitions in total, not definitions for each quick form. For the menu I added cache tags so it will be rebuilt when 1) config entities are added/deleted or 2) when config entities are updated (needed for detecting changes to
status).I have a few additional commits/changes:
- Use standard entity permissions (view/update/create/delete). We only use view + update for now but the entity permission provider gives us all. Without these permissions the quick form config entity was not viewable from the API, even for admin user. I think having this available via API will be useful in the long run.
- Raise 404 for invalid quick form IDs
- Consistency between
QuickFormInstanceManagerfunctionsgetInstancesandgetInstance(renamed fromcreateInstance)Comment #11
paul121 commentedAdded a few fixup commits to fix the schema issue, phpstan dependency injection and a separate bug in the tests
Comment #12
m.stentaI finished the docs and automated tests yesterday. All tests are passing in my branch in GitHub Actions. This is ready for review. I will open a pull request on GitHub for others in the farmOS community to review.
Comment #15
m.stenta