Difference between revisions of "How to add special validation for some fields on signup form"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "Create /amember/application/configs/site.php with this code: <source> <?php Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm'); function siteVa...")
 
Line 8: Line 8:
 
{
 
{
 
     $form = $event->getForm();
 
     $form = $event->getForm();
     /* @var $email HTML_QuickForm2_Element */
+
     $vars = $form->getValue();
    list($email, ) = $form->getElementsByName('email');
+
    if ($vars['email'] != 'test') {
    if ($email != 'test')
+
        /* @var $email HTML_QuickForm2_Element */
         $email->setError('Some Error Occured!');
+
        list($email, ) = $form->getElementsByName('email');
 +
         $email->setError('Some Error Accured!');
 +
    }
 
}
 
}
 
</source>
 
</source>

Revision as of 02:41, 10 January 2013

Create /amember/application/configs/site.php with this code:

<?php
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm');
 
function siteValidateForm(Am_Event_ValidateSavedForm $event)
{
    $form = $event->getForm();
    $vars = $form->getValue();
    if ($vars['email'] != 'test') {
        /* @var $email HTML_QuickForm2_Element */
        list($email, ) = $form->getElementsByName('email');
        $email->setError('Some Error Accured!');
    }
}