Standardize ACF form submission
A form action needs to know whether you’re requesting the form fields and current values, or submitting the form with new values. For web forms, we check for the presence of the parameter with the name of the submit button. That name is specified by the controller in the cfe ‘option’ field. This ‘option’ field is used as the name and label of the submit button for a web form (see viewfunctions.lua). For instance, the /alpine-baselayout/interfaces/editintfile action requires the form to pass in “Save”, whereas the /alpine-baselayout/interfaces/create action requires the form to pass in “Create”.
For the cli application, the user must pass in this field to indicate that he is submitting the form. This is quite non-obvious.
The startstop action is an exception. The submit name is “action” and the value is one of the possible actions (ie. Start). The available actions are passed to the view in the actions field.
Another exception is actions that change the system but don’t have a form or a view. Examples are /acf-util/password/deleteuser and /acf-util/skins/update. These actions take input parameters, but there is no form notifying the client application what inputs are needed. This makes the cli application difficult to use - the user must have intimate knowledge of how these actions work. These actions use self:redirect_to_referrer, which also means that redirecting the result to another page does not work.
It’s probably a good idea to standardize all actions that make a change on the system to be forms that take the same parameter name, like “submit”, to indicate that the form is being submitted. The value of the submit parameter could be used for actions like startstop that have multiple possible actions. This makes everything consistent, and also makes a real cli application possible.
Implementing this is mostly changing the library functions for existing forms. For self:redirect_to_referrer actions, they would have to change to forms. This involves creating a new function to create the form fields, and creating a view.
It would be nice if we could create a generic form view, now that we have the ability to specify the order of parameters in the cfe, that would be automatically used for forms that do not have views. This would allow us to get rid of a whole bunch of view files that simply specify the parameter order.
Obviously, this is a big change and would require updates to (almost) every acf package.
(from redmine: issue id 648, created on 2011-05-18, closed on 2012-08-21)
- Relations:
- relates #643 (closed)