Difference between revisions of "Custom Signup Forms"

From aMember Pro Documentation
Jump to: navigation, search
(How to build a 100% custom signup form)
Line 32: Line 32:
  
 
</source>
 
</source>
* Go to ''aMember Cp -> Forms Editor'' and create new form for testing. In the "Template" field choose "signup_custom.phtml". Save
+
* Go to ''aMember Cp -> Forms Editor'' and create new form for testing. In the "Template" field choose ''signup_my_custom.phtml''. Save
 
* Open your new form. You will see form generated by your new template. You can tweak HTML code to display input fields in desired positions on the page.
 
* Open your new form. You will see form generated by your new template. You can tweak HTML code to display input fields in desired positions on the page.
  
 
To see contents of $frm variable, uncomment line  
 
To see contents of $frm variable, uncomment line  
 
<source lang="php">echo '<pre>'.htmlentities(print_r($frm, true)).'</pre>'; // dump elements to your review</source>
 
<source lang="php">echo '<pre>'.htmlentities(print_r($frm, true)).'</pre>'; // dump elements to your review</source>

Revision as of 09:45, 19 September 2012

aMember Pro allows easy editing of signup forms via aMember Cp -> Forms Editor. Visual form editor is very flexible and easy to use, and it is quite enough for 99% customers.

However, form editor may anyway be not flexible enough for advanced customers. So if you have strong PHP, HTML and JavaScript skills, this guide will allow you to build 100% custom signup forms and still use aMember form handling and Javascript.

How to build a 100% custom signup form

  • Create a new file amember/application/default/views/signup/signup_my_custom.phtml with the following content
<?php
$title = 'Signup'; // set title for usage in header
 
$this->setLayout('layout.phtml'); // include header and footer around this page
 
include $this->_script('_error.phtml'); // display error if any
 
$frm = $this->form->renderEasyArray(); // get html elements to include into your custom html
//echo '<pre>'.htmlentities(print_r($frm, true)).'</pre>'; // dump elements to your review
?>
<form class="am-form" <?php echo $frm['attributes'];?>>
<?php echo $frm['hidden'];// insert hidden elements to the form - REQUIRED ?>
<?php echo $frm['javascript']; // insert javascript code to the form - REQUIRED ?>
    <b>Products</b>: 
        <?php echo $frm['elements']['product_id-0']['htmle'] ?>
        <!-- ['htmle'] combines the element HTML and error message 
             You may use separate ['html'] and ['error'] elements 
             instead of ['htmle'] -->
    <hr /> 
    <b>Paysystem</b>: 
        <?php echo $frm['elements']['paysys_id']['htmle'] ?>
    <hr />
        <?php echo $frm['elements']['buttons']['htmle'] ?>
</form>
  • Go to aMember Cp -> Forms Editor and create new form for testing. In the "Template" field choose signup_my_custom.phtml. Save
  • Open your new form. You will see form generated by your new template. You can tweak HTML code to display input fields in desired positions on the page.

To see contents of $frm variable, uncomment line

echo '<pre>'.htmlentities(print_r($frm, true)).'</pre>'; // dump elements to your review