Jump to content

Retrieving data from template


Ron Record

Recommended Posts

I have added an element to the Nav Bar which when clicked brings up a Custom Page with a template I wrote that presents the user with a form.

What is the best/recommended method of retrieving the form data when the user clicks the Submit button?

For example, my template includes a field for the user's first name as follows:

<input type="text" name="firstname" id="inputFirstName" value="{$clientfirstname}"{if in_array('firstname', $uneditablefields)} disabled="disabled"{/if} class="form-control" />

Is there an easier WHMCS way of retrieving the user's first name as entered on the template form other than the typical PHP way of something like:

 // Check if the form is submitted
if ( isset( $_POST['submit'] ) ) {
// retrieve the form data by using the element's name attributes value as key
$firstname = $_REQUEST['firstname'];

Or, is it the case that $clientfirstname is passed back to the custom page along with the other form variable values?

Thanks for any help - I am fairly new to WHMCS so feel free to treat me like a child 🙂

Link to comment
Share on other sites

No responses to my question but I have sufficiently resolved this. At least to my current satisfaction. The answer is yes, you can utilize typical PHP way of retrieving form data. Something like:

if ($action == "someactionthetemplateset") {
            $ca->setTemplate('sometemplateyouwant');
            $ca->addToBreadCrumb("companyuserdetails.php?action=someactionthetemplateset",
                                 'Add Company User');
            $firstname = isset($_POST['firstname']) ? $_POST['firstname'] : '';

And so on for the values from the form in the template.

There may be some $whmcs magic that is available to the module or hook in retrieving form data or variable values from a template but I do not find it in the documentation so for now I am just using something like the above.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated