OpenMage

...fieldset->addField('toefl_pbt', 'text', [ 'name' => 'toefl_pbt', 'label' => Mage::helper('course')->__('TOEFL PBT'), 'class' =>'validate-number-range number-range-310-677', 'note' => Mage::helper('course')->__('Lowest TOEFL PBT score...

...addField('contact_email', 'text', array( 'name' => 'contact_email', 'label' => Mage::helper('swms')->__('Contact Email'), 'class' => 'validate-email' )); $fieldset->addField('nec', 'text', array( 'name' => 'nec', 'label' => Mage::helper('course')->__('NEC'),

OpenMage

...s the list of classes available to add to your field elements: required (not blank) validate-number (a valid number) validate-digits (digits only) validate-alpha (letters only) validate-alphanum...

...only letters and numbers) validate-date (a valid date value) validate-email (a valid email address) validate-url (a valid URL) validate-date-au (a date formatted as; dd/mm/yyyy)

...Error Handling in Controller Ref: app\code\core\Mage\Adminhtml\controllers\CustomerController.php public function validateAction() { $response = new Varien_Object(); $response->setError(0); // ... if ($errors !== true) { foreach ($errors as $error) { $this...

$(area).update(transport.responseText); } } catch (e) { $(area).update(transport.responseText); } } }); } } ./js/mage/adminhtml/form.js varienForm.prototype = { initialize : function(formId, validationUrl){ this.formId = formId; this.validationUrl = validationUrl; this.submitUrl = false; if($(this.formId)){ this.validator = new Validation(this.formId, {onElementValidate : this.checkErrors.bind(this...

github.com

...html = $this->getLayout()->createBlock('core/html_select') ->setName($name) ->setId($id) ->setTitle(Mage::helper('directory')->__($title)) ->setClass('validate-select') ->setValue($defValue) ->setOptions($options) ->getHtml(); Varien_Profiler::stop('TEST: '.__METHOD__); return $html; }

...mixed, option_id => mixed...) * @return Mage_Catalog_Model_Product_Option_Type_Default */ public function validateUserValue($values) { parent::validateUserValue($values); $option = $this->getOption(); $value = $this->getUserValue(); if (empty($value) && $option->getIsRequire...

Best results in other decks

If you have a :string or :text field, you should pair it with a model validation that restricts its length...

The Truemail gem (not to be confused with truemail.io) allows validating email addresses, e.g. when users enter them into a...

Search in all decks