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

From aMember Pro Documentation
Jump to: navigation, search
 
Line 1: Line 1:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm');
+
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, function (Am_Event_ValidateSavedForm $event) {
 
+
function siteValidateForm(Am_Event_ValidateSavedForm $event)
+
{
+
 
     $form = $event->getForm();
 
     $form = $event->getForm();
 
     $vars = $form->getValue();
 
     $vars = $form->getValue();
Line 10: Line 7:
 
         $event->addError('Some Error Accured!');
 
         $event->addError('Some Error Accured!');
 
     }
 
     }
}
+
});
 
</source>
 
</source>

Latest revision as of 05:03, 5 February 2016

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, function (Am_Event_ValidateSavedForm $event) {
    $form = $event->getForm();
    $vars = $form->getValue();
    if (isset($vars['email']) && ($vars['email'] != 'test')) { // perform some validation
        $event->addError('Some Error Accured!');
    }
});