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 a ConfigurableQuickFormInterface that quick forms can use to declare themselves configurable.
  • Provide a ConfigurableQuickFormTrait that quick forms can use for default methods.
  • Provide a QuickFormInstanceManager service 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 a requiresEntity property to quick form plugins to optionally prevent creating default instances.
  • Add a configure quick forms permission, granted to managed roles with "config" level access.
  • Add a ConfigureQuickForm for building, validating, and submitting configuration forms.
  • Save configuration entities when ConfigureQuickForm is 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

Command icon 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

m.stenta created an issue. See original summary.

elber’s picture

Assigned: Unassigned » elber

Hi @m.stenta do you want something like that (https://www.drupal.org/project/bigmenu/issues/3348166) create a configuration form?

m.stenta’s picture

Assigned: elber » m.stenta
Status: Active » Needs work

Oh 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...

elber’s picture

ok don't worry I can do the review when you finish if you want.

m.stenta’s picture

Issue summary: View changes

Updated 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

m.stenta’s picture

The remaining tasks are:

  • Finish documentation - I've already started this, but there are a few details I would like to add. Specifically: documenting the new methods available for configurable quick forms, how to use the requiresEntity attribute, and perhaps how to disable quick forms via their config entities.
  • Automated tests - I've started this, but there's a fair bit more to do with it.
  • Save config entity in submitConfigurationForm() - there's a @todo in code for this. But it may also be affected by the next item...
  • Extend ConfigureQuickForm from EntityForm to handle boilerplate config entity adding/updating logic.
  • Refactor route building logic into a single route - Currently routes need to be rebuilt whenever a config entity is added/deleted.
m.stenta’s picture

Refactor route building logic into a single route - Currently routes need to be rebuilt whenever a config entity is added/deleted.

Hmm does this also affect menu links and tasks? Do we need to ensure those are re-generated when config entities are added/deleted?

m.stenta’s picture

Another question came up on the call w/ @paul121 today: What happens to quick form actions when you disable a quick form?

paul121 made their first commit to this issue’s fork.

paul121’s picture

Save config entity in submitConfigurationForm() - there's a @todo in code for this. But it may also be affected by the next item...
Extend ConfigureQuickForm from EntityForm to handle boilerplate config entity adding/updating logic.
Refactor route building logic into a single route - Currently routes need to be rebuilt whenever a config entity is added/deleted.

These items are done!

Do we need to ensure those are re-generated when config entities are added/deleted?

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 QuickFormInstanceManager functions getInstances and getInstance (renamed from createInstance)

paul121’s picture

Automated tests - I've started this, but there's a fair bit more to do with it.

Added a few fixup commits to fix the schema issue, phpstan dependency injection and a separate bug in the tests

m.stenta’s picture

Status: Needs work » Needs review

I 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.

  • m.stenta committed 87991481 on 2.x
    Add CHANGELOG.md lines for Issue #3354935: Configurable quick forms
    
m.stenta’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.