Problem/Motivation
The forms a decoupled front end draws are handed to it by the static data endpoint, and today that list is three definitions written out in PHP: their machine names, their fields, their titles and the endpoint each submits to. It is the last place in the module where the shape of a site is a literal rather than something read from it, and it has the two failure modes literals always have. A site with a fourth form cannot get it into the list without editing the module, and a site that keeps its forms in something other than core's contact module cannot appear in the list at all.
The second half is worse and easy to miss: describing a form is only half of it. A front end that has been told which fields to draw still needs somewhere to send them, and that endpoint is written by hand today, one class per form. So a generated model can describe a form it cannot accept.
Proposed resolution
- Read the forms rather than list them: a form is an entity of some type, and which type is the site's business - core's contact form is one answer and not the only one.
- Describe a form from what it actually has - its fields, their types, which are required - the same way the scanner describes a bundle, instead of from a hand-written list of field names.
- Generate the submission endpoint beside the description. A described form that nothing accepts is a form the front end can draw and cannot send.
- Let a form that belongs to some other entity be served from there as well, rather than only from the one list: a form attached to a page is part of that page.
- Keep every form module optional, as everything else in this project is: no contact module, no contact forms, no error.
Remaining tasks
Everything.
Issue fork myrest-3623899
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 #4
sergeydruua commentedComment #6
sergeydruua commented