How do I include a PHP file that handles the action for a custom form of mine?
Only trouble is that I can't for the life of me figure out how to indicate the action of the form as a PHP script I have been using.
I don't mean how form actions are indicated in normal, easily understood HTML form constructs.
I mean inside C5.
For example what in the world does the following code do respecting the action of the form?
That's like gibberish to me or nearly so.
I mean I know the "<form enctype="multipart/form-data" id="miniSurveyView<?php echo" part. That's easy.
But what is intval($bID)? Some kind of ID obviously but to what? And what is the purpose of this ID? Is it a CSS ID?
Why the use of intval()?
What does "$this->action('submit_form').'#'.$survey->questionSetId?>"
Is 'submit_form' some sort of stock action? What does survey have to do with a form? Why are we attaching some sort of # to the action of the form?
And most importantly how in the world do I insert my own action in the form of a PHP file that I want to have the form run every time the form is submitted?
I've been sitting here for the better part of an hour staring at my computer and I still haven't got a clue.
If anyone might be willing to help me through this action confusion I would very much appreciate it.
$bID is the block ID. It is often appended to HTML id's to ensure that elements on the page have unique id's (in case there is more than 1 of a block added to a page -- if they were both "miniSurveyView", you wouldn't know which is which -- whereas if one is "miniSurveyView78" and the other is "miniSurveyView79", now you can uniquely identify each one).
The intval ensures that it is a number. It's totally unnecessary in this case, I'm not sure why it's there. But in other situations you use it to make sure you're getting an integer number instead of a string or a "float" (number with decimal places) -- sometimes useful if trying to validate the value of a form field or of a querystring parameter ($_GET['...']) because you can't trust that users will always enter the kind of data your code expects. But again, since the $bID comes from the C5 system in this case, I'm not sure why it's there -- probably just a habit of whoever coded it up originally.
$this->action('submit_form') is how you get the url to a specific function in your controller (a function other than "view()", which is the default if you don't specify an action). You need to look at the form block's controller.php file to see what this is about -- there is a function in there called action_submit_form which handles form submissions. I don't know what the #surveyQuestionSetId thing is for (probably left over from some experiment at one time but never taken out).
A really helpful technique for figuring out what various templates are doing is to view the source of the page in the browser. Then you would see what it is that is actually getting outputted by all the various php variables (like $bID and $this->action()).
Hope that helps.
Anyway I will work with the external block then and do what you suggest Jordan. Namely look at the source and put a bunch of echo's in the relevant code to see which pieces of the final page output come from where.
I don't know what else to say other than thanks again Jordan!