Form Block - Access submitted values in controller.php
Permalink
Hello -
I am modifying the Forms block in C5 so that the data submitted from a form block would integrate into highrise.
I've found the correct placement for my shell script within the controller.php file. I've verified that my script works - it works just fine without the form variables.
My shell command is: shell_exec('php /Library/Webserver/Documents/blocks/form/addperson.php HighRiseUser HighRiseAPI'. ' ' .$first. ' ' .$last. ' ' .$email. ' ' .$tele. ' ' .$message);
where the $first/$last/$email are variables $_POST'd from the from.
My question is this: What is the easiest way to get all the fields from the form block into an array inside controller.php (if there isn't an array already that I use)?
Thank you,
Lee Salminen
I am modifying the Forms block in C5 so that the data submitted from a form block would integrate into highrise.
I've found the correct placement for my shell script within the controller.php file. I've verified that my script works - it works just fine without the form variables.
My shell command is: shell_exec('php /Library/Webserver/Documents/blocks/form/addperson.php HighRiseUser HighRiseAPI'. ' ' .$first. ' ' .$last. ' ' .$email. ' ' .$tele. ' ' .$message);
where the $first/$last/$email are variables $_POST'd from the from.
My question is this: What is the easiest way to get all the fields from the form block into an array inside controller.php (if there isn't an array already that I use)?
Thank you,
Lee Salminen
Hey Jordan-
That form block you have on Github is great! I got it to work just fine with your templated block.
Ideally, we would like to integrate with the default forms block. That way we don't lose functionality (survey questions, file attachment etc...).
Is there an existing function that can pull Question(HTML labels)/Answer(HTML input values) pairs into an associative array?
With that array, I plan on matching the Question (HTML label) to firstname/lastname/email etc... and if the question label matches up then assign the Answer (input value) to a variable in PHP.
That form block you have on Github is great! I got it to work just fine with your templated block.
Ideally, we would like to integrate with the default forms block. That way we don't lose functionality (survey questions, file attachment etc...).
Is there an existing function that can pull Question(HTML labels)/Answer(HTML input values) pairs into an associative array?
With that array, I plan on matching the Question (HTML label) to firstname/lastname/email etc... and if the question label matches up then assign the Answer (input value) to a variable in PHP.
I don't know the code off the top of my head -- but like I said, if you look at how the dashboard reporting does it, I'm sure there's some code in there that does this somehow or another.
But if you need it to work with the built-in form block (because the fields are different from place to place on the site or you need to allow your users to modify the fields over time), then I'd suggest looking at the code for the dashboard page that shows the "report" of form submissions -- in concrete/controllers/dashboard/reports/forms
It's tricky because there's no simple table for form answers. Because each form can have different fields, there are several database tables that are put together to make a single form submission as a whole (one for questions, one for answer choices, one for the submissions, one for the submission's answers to specific questions, etc.).
Good luck!