C5-8.0+ How to execute PHP function and pass json values from add block form?
Permalink
How can I execute a PHP function in the block controller and pass json values to it from an Add Block form, for example, on closing the form I want to save some form data (not from inputs) in the database:
There is also a save($args) function, but how do I append my json array to the $args?
Thank you.
$('#ccm-form-submit-button').on('click', function(e){
There is also a save($args) function, but how do I append my json array to the $args?
Thank you.
you are sending data 2 ways here. You are sending your data object with a POST but you are sending your token as a query parameter, so that would be a GET. What's more you're indicating JSON as data type but using query parameters makes it HTML I think.
Anyway, I think this tutorial should help you out:
https://documentation.concrete5.org/developers/working-with-blocks/c...
Maybe this one as well
https://documentation.concrete5.org/developers/working-with-blocks/c...
Anyway, I think this tutorial should help you out:
https://documentation.concrete5.org/developers/working-with-blocks/c...
Maybe this one as well
https://documentation.concrete5.org/developers/working-with-blocks/c...
form.php
controller.php:
But the token ('message' => $token) is null. Why isn't it passed to the controller?
What am I missing?