Allow form actions to update 'fields' & 'thanks' data#243
Conversation
6c69e42 to
de4ea50
Compare
de4ea50 to
9afb8d4
Compare
|
Is there anything preventing this from being merged ? |
|
@micgro42 after your processing of my other 3 PR's, maybe there is a chance you can review and merge this one as well ? Thanks in advance ! |
9afb8d4 to
463d17c
Compare
|
It would be appreciated if you guys could merge this PR, or let me know if there is something I need to do before you do so. Thanks ! |
|
Just a friendly bump 😃 |
|
If I get it right, this patch could also solve the problem I am having in the linked message, if I create a hidden "result" field in the form and fill its value with the result of the calculation from the script. Thus, a big +1 from my part for this PR. :-) PS: However, I would need a more explicit example about how to access the single fields in the action script; unfortunately, the example on the page of the bureaucracy plugin showing how to write the value of the fields in a log is not helpful for me, as I am not a developer. |
|
The following RFE might also become redundant, as it would be possible to act on the data submitted by the user in the form before passing it to the email template. |
|
Thanks for your interest and support @frafum 😃 Unfortunately, considering that I first raised this issue over a year ago (#223) and despite multiple reminders never got any kind of feedback from the powers that be except for a request to submit a pull request, I'm afraid that there is not much interest in this feature from their end 😞 |
463d17c to
ee5fc48
Compare
|
For me the feature is fine. But I didn't have look in how it really works. I don't know yet an idea what the script action is actually doing. @micgro42 or @splitbrain did introduce the script action and they are building more complex stuff with this plugin. So I hope they could have a technical look into it. |
|
Thanks for the feedback @Klap-in. To clarify and maybe facilitate the review process: the PR does not introduce any change in behavior (i.e. the script action works exactly as it did before). The only thing it does is allowing an action script to update the parameters it receives, since they are now passed by reference. This enables action chaining, e.g. Assuming update.php does something like appending text function handleData(&$fields, &$thanks) {
$fields[0]->setVal($fields[0]->getParam('value') . "_updated");
return ''; // return empty string a we don't want to display anything at this time
}Submitting the form with
That's all. Of course, since the handleData method's signature has changed merging the PR would introduce a regression for existing scripts as PHP would throw Fatal error: Declaration of helper_plugin_bureaucracy_handler_XXX::handleData($fields, $thanks) must be compatible with dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface::handleData(&$fields, &$thanks). Adapting them is as simple as adding the |
ee5fc48 to
f98b98f
Compare
|
I am still hoping that this would get merged in at some point... Please ? 🙏 |
|
This API change will break all the plugins that extends the bureaucracy classes(struct plugin for example) and although I like the idea, we must also preserve backwards compatibility. I will think about it. Maybe it can be done by some dokuwiki event? @dregad do you have any idea? |
|
@solewniczak thanks for responding and looking into this ! 😃 I'm sorry I do not know enough about the internals of dokuwiki event system to really be able to help in this area, and I can't think of any other way to achieve the objective at the moment. While it is true that the approach I proposed it would break dependent plugins due to the modified function signatures, please consider that the change is very simple. (just adding a Moreover, I don't think there are that many plugins out there that extend these methods, so adapting the struct plugin (and any others) wouldn't require a big effort - to avoid any regression, the child class only needs to be checked to ensure the updated functions are not altering the parameters' values, and store them in a local variable if they are. Finally, considering that PHP would throw error/warning messages due to the modified signature, it would be easy to detect if and where corrective action is required. |
|
I had a look at struct plugin's code. Note that I don't use it myself, so I don't really know how it works and my analysis may therefore not be sufficient. Anyway, AFAICT there are only 2 occurrences of classes extending bureaucracy:
Hope this helps. |
|
@solewniczak any update ? |
|
Friendly bump... Some feedback would be nice 🙏 |
|
@solewniczak A breaking change could be issued for the Bureaucracy plugin with a major version bump. This seems like really useful functionality to add. |
|
@iainhallam thanks for your support. Unfortunately, after 4 years, multiple reminders and additional analysis to respond to compatibility concerns, it is sadly quite obvious by now that the plugin maintainers have zero interest in merging this feature... 😞 |
|
friendly bump... |
- $fields and $thanks parameters are passed by reference in bureaucracy_handler_interface::handleData() and helper_plugin_bureaucracy_action::run() methods (including descendants). - helper_plugin_bureaucracy_field::setVal() method is now public This allows "chaining" of several actions in a single form, enabling e.g. a script action handler to pre-process submitted data before it is passed on to a template or mail action. Fixes splitbrain#223
f98b98f to
abd58f2
Compare
This allows "chaining" of several actions in a single form, enabling e.g. a script action handler to pre-process submitted data before it is passed on to a template or mail action.
Fixes #223