本文整理汇总了PHP中Zend_Form_Element_Text::getValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Text::getValidator方法的具体用法?PHP Zend_Form_Element_Text::getValidator怎么用?PHP Zend_Form_Element_Text::getValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Text
的用法示例。
在下文中一共展示了Zend_Form_Element_Text::getValidator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', DOMAIN . 'workeligibilitydoctypes/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'workeligibilitydoctypes');
$id = new Zend_Form_Element_Hidden('id');
$documenttype = new Zend_Form_Element_Text('documenttype');
$documenttype->setAttrib('maxLength', 50);
$documenttype->setRequired(true);
$documenttype->addValidator('NotEmpty', false, array('messages' => 'Please enter document type.'));
$documenttype->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9\\-\\s]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid document type.')));
$documenttype->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_workeligibilitydoctypes', 'field' => 'documenttype', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$documenttype->getValidator('Db_NoRecordExists')->setMessage('Document type already exists.');
$issuingauthority = new Zend_Form_Element_Select('issuingauthority');
$issuingauthority->setRegisterInArrayValidator(false);
$issuingauthority->setMultiOptions(array('' => 'Select issuing authority', '1' => 'Country', '2' => 'State', '3' => 'City'));
$issuingauthority->setRequired(true);
$issuingauthority->addValidator('NotEmpty', false, array('messages' => 'Please select issuing authority.'));
$description = new Zend_Form_Element_Textarea('description');
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $documenttype, $issuingauthority, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例2: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'positions');
$id = new Zend_Form_Element_Hidden('id');
$emptyflag = new Zend_Form_Element_Hidden('emptyFlag');
$positionname = new Zend_Form_Element_Text('positionname');
$positionname->setAttrib('maxLength', 50);
$positionname->setRequired(true);
$positionname->addValidator('NotEmpty', false, array('messages' => 'Please enter position.'));
$positionname->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\-\\s]*$/i', 'messages' => array('regexNotMatch' => 'Please enter valid position.')))));
$positionname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_positions', 'field' => 'positionname', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$positionname->getValidator('Db_NoRecordExists')->setMessage('Position already exists.');
$jobtitleid = new Zend_Form_Element_Select('jobtitleid');
$jobtitleid->setAttrib('class', 'selectoption');
$jobtitleid->setRegisterInArrayValidator(false);
$jobtitleid->addMultiOption('', 'Select Job Title');
$jobtitleid->setRequired(true);
$jobtitleid->addValidator('NotEmpty', false, array('messages' => 'Please select job title.'));
$description = new Zend_Form_Element_Textarea('description');
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $positionname, $jobtitleid, $description, $emptyflag, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例3: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', BASE_URL . 'timemanagement/expensecategory/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'expensecategory');
$id = new Zend_Form_Element_Hidden('id');
$category = new Zend_Form_Element_Text('expense_category');
$category->setAttrib('maxLength', 200);
$category->setLabel("Category");
$category->setRequired(true);
$category->addValidator('NotEmpty', false, array('messages' => 'Please enter Category.'));
$category->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid Category.')));
$category->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'tm_expense_categories', 'field' => 'expense_category', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and is_active=1')));
$category->getValidator('Db_NoRecordExists')->setMessage('Category already exists.');
//http://stackoverflow.com/questions/9299012/using-for-decimals-in-zend-validator-float
$unitPrice = new Zend_Form_Element_Text('unit_price');
$unitPrice->setAttrib('maxLength', 7);
$unitPrice->setLabel("Unit Price");
$unitPrice->addValidator("regex", true, array('pattern' => '/^[1-9]+(\\.\\d{1,2})?$/', 'messages' => array('regexNotMatch' => 'Please enter valid price.')));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $category, $unitPrice, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例4: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', DOMAIN . 'monthslist/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'monthslist');
$id = new Zend_Form_Element_Hidden('id');
$monthname = new Zend_Form_Element_Select('month_id');
$monthname->setAttrib('class', 'selectoption');
$monthname->setRegisterInArrayValidator(false);
$monthname->setRequired(true);
$monthname->addValidator('NotEmpty', false, array('messages' => 'Please select month name.'));
$monthcode = new Zend_Form_Element_Text('monthcode');
$monthcode->setAttrib('maxLength', 20);
$monthcode->addFilter(new Zend_Filter_StringTrim());
$monthcode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_monthslist', 'field' => 'monthcode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$monthcode->getValidator('Db_NoRecordExists')->setMessage('Month code already exists.');
$description = new Zend_Form_Element_Textarea('description');
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$url = "'monthslist/saveupdate/format/json'";
$dialogMsg = "''";
$toggleDivId = "''";
$jsFunction = "'redirecttocontroller(\\'monthslist\\');'";
$this->addElements(array($id, $monthname, $monthcode, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例5: _setupElements
private function _setupElements()
{
$translate = Zend_Registry::get('Zend_Translate');
$this->setAttrib('id', 'signupForm');
$this->setTranslator($translate);
$email = new Zend_Form_Element_Text('email');
$email->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->addValidator('NotEmpty')->removeDecorator('HtmlTag')->removeDecorator('DtDWrapper')->removeDecorator('label')->setAttrib('id', 'email')->addValidator('EmailAddress');
$email->addValidator(new Ziown_Form_Validate_EmailAddress(), false);
$email->getValidator('NotEmpty')->setMessage('Email Address is Required', 'isEmpty');
$username = new Zend_Form_Element_Text('username');
$username->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->addValidator('NotEmpty')->removeDecorator('HtmlTag')->removeDecorator('DtDWrapper')->removeDecorator('label')->setAttrib('id', 'username');
$username->addValidator(new Ziown_Form_Validate_UserName());
$username->getValidator('NotEmpty')->setMessage('User name is Required', 'isEmpty');
$password = new Zend_Form_Element_Password('password');
$password->setRequired(true)->removeDecorator('HtmlTag')->removeDecorator('DtDWrapper')->removeDecorator('label')->setAttrib('id', 'txt-password')->setErrorMessages(array('Password is required'));
$identValidator = new Zend_Validate_Identical($_POST['password']);
$identValidator->setMessages(array('notSame' => 'Password doesn\'t match!', 'missingToken' => 'Password doesn\'t match!'));
$confirm_password = new Zend_Form_Element_Password('confirm_password');
$confirm_password->setRequired(true)->removeDecorator('HtmlTag')->removeDecorator('DtDWrapper')->removeDecorator('label')->setAttrib('id', 'txt-confirm-password')->addValidator($identValidator);
$signup = new Zend_Form_Element_Submit('signup');
$signup->setLabel('Sign Up');
$signup->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('class', 'u-login');
$this->setDecorators(array(array('ViewScript', array('script' => 'signup.phtml'))));
$this->addElements(array($username, $password, $confirm_password, $signup, $email));
}
示例6: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', BASE_URL . 'veteranstatus/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'veteranstatus');
$id = new Zend_Form_Element_Hidden('id');
$veteranstatus = new Zend_Form_Element_Text('veteranstatus');
$veteranstatus->setAttrib('maxLength', 20);
$veteranstatus->setRequired(true);
$veteranstatus->addValidator('NotEmpty', false, array('messages' => 'Please enter veteran status.'));
$veteranstatus->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z\\s]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid veteran status.')))));
$veteranstatus->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_veteranstatus', 'field' => 'veteranstatus', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$veteranstatus->getValidator('Db_NoRecordExists')->setMessage('Veteran status already exists.');
$description = new Zend_Form_Element_Textarea('description');
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$url = "'gender/saveupdate/format/json'";
$dialogMsg = "''";
$toggleDivId = "''";
$jsFunction = "'redirecttocontroller(\\'gender\\');'";
$this->addElements(array($id, $veteranstatus, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例7: init
public function init()
{
$this->setMethod('post');
//$this->setAttrib('action',DOMAIN.'language/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'servicedeskdepartment');
$id = new Zend_Form_Element_Hidden('id');
$servicedeskdepartment = new Zend_Form_Element_Text("service_desk_name");
$servicedeskdepartment->setLabel("Category");
$servicedeskdepartment->setAttrib('maxLength', 30);
$servicedeskdepartment->addFilter(new Zend_Filter_StringTrim());
$servicedeskdepartment->setRequired(true);
$servicedeskdepartment->addValidator('NotEmpty', false, array('messages' => 'Please enter category.'));
$servicedeskdepartment->addValidator("regex", true, array('pattern' => '/^[a-zA-Z0-9\\- ]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid category.')));
$servicedeskdepartment->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_sd_depts', 'field' => 'service_desk_name', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" AND isactive=1')));
$servicedeskdepartment->getValidator('Db_NoRecordExists')->setMessage('Category name already exists.');
$description = new Zend_Form_Element_Textarea('description');
$description->setLabel("Description");
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $servicedeskdepartment, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例8: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'pdcategories');
$this->setAttrib('name', 'pdcategories');
$categoryName = new Zend_Form_Element_Text('category');
$categoryName->setAttrib('id', 'category');
$categoryName->setAttrib('name', 'category');
$categoryName->setAttrib('maxlength', '30');
$categoryName->setAttrib('onblur', 'chkCategory()');
$categoryName->setAttrib('onkeypress', 'chkCategory()');
$categoryName->addFilter(new Zend_Filter_StringTrim());
$categoryName->setRequired(true);
$categoryName->addValidator('NotEmpty', false, array("messages" => 'Please enter category'));
$categoryName->addValidator('regex', true, array('pattern' => '/^[a-zA-Z0-9][\\s+[a-zA-Z0-9]+]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid category')));
$categoryName->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_pd_categories', 'field' => 'category', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive = 1')));
$categoryName->getValidator('Db_NoRecordExists')->setMessage('Category already exists');
$categoryDesc = new Zend_Form_Element_Textarea('description');
$categoryDesc->setAttrib('id', 'description');
$categoryDesc->setAttrib('name', 'description');
$categoryDesc->setAttrib('rows', 10);
$categoryDesc->setAttrib('cols', 50);
$categoryDesc->setAttrib('maxlength', 250);
$submitBtn = new Zend_Form_Element_Submit('submit');
$submitBtn->setAttrib('id', 'submitBtn');
$submitBtn->setLabel('Add');
$this->addElements(array($categoryName, $categoryDesc, $submitBtn));
$this->setElementDecorators(array('ViewHelper'));
}
示例9: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'emailcontacts');
$this->setAttrib('action', BASE_URL . 'emailcontacts/add/');
$id = new Zend_Form_Element_Hidden('id');
$group_id = new Zend_Form_Element_Select("group_id");
$group_id->setRegisterInArrayValidator(false);
$group_id->setRequired(true);
$group_id->addValidator('NotEmpty', false, array('messages' => 'Please select group.'));
$business_unit_id = new Zend_Form_Element_Select("business_unit_id");
$business_unit_id->setRegisterInArrayValidator(false);
$business_unit_id->setRequired(true);
$business_unit_id->addValidator('NotEmpty', false, array('messages' => 'Please select business unit.'));
$business_unit_id->setAttrib('onchange', "bunit_emailcontacts('business_unit_id');");
//Group Email....
$grpEmail = new Zend_Form_Element_Text('groupEmail');
$grpEmail->addFilters(array('StringTrim', 'StripTags'));
$grpEmail->setRequired(true);
$grpEmail->addValidator('NotEmpty', false, array('messages' => 'Please enter group email.'));
$grpEmail->addValidator("regex", true, array('pattern' => '/^(?!.*\\.{2})[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid email.')));
$grpEmail->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_emailcontacts', 'field' => 'groupEmail', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive = 1')));
$grpEmail->getValidator('Db_NoRecordExists')->setMessage('Group email already exists.');
// Form Submit .........
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $group_id, $grpEmail, $submit, $business_unit_id));
$this->setElementDecorators(array('ViewHelper'));
}
示例10: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', DOMAIN . 'attendancestatuscode/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'attendancestatuscode');
$id = new Zend_Form_Element_Hidden('id');
$attendancestatuscode = new Zend_Form_Element_Text('attendancestatuscode');
$attendancestatuscode->setAttrib('maxLength', 20);
//$attendancestatuscode->addFilter(new Zend_Filter_StringTrim());
$attendancestatuscode->setRequired(true);
$attendancestatuscode->addValidator('NotEmpty', false, array('messages' => 'Please enter attendance status.'));
$attendancestatuscode->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid attendance status.')));
$attendancestatuscode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_attendancestatuscode', 'field' => 'attendancestatuscode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$attendancestatuscode->getValidator('Db_NoRecordExists')->setMessage('Attendance status already exists.');
$description = new Zend_Form_Element_Textarea('description');
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $attendancestatuscode, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例11: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', DOMAIN . 'dashboard/viewprofile');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'profileview');
$id = new Zend_Form_Element_Hidden('id');
$userfullname = new Zend_Form_Element_Text("userfullname");
$userfullname->setLabel("User Name");
$userfullname->setAttrib("class", "formDataElement");
$userfullname->setAttrib('length', 70);
$userfullname->setRequired(true);
$userfullname->addValidator('NotEmpty', false, array('messages' => 'Please enter user name.'));
$userfullname->addValidator("regex", true, array('pattern' => '/^([a-zA-Z.]+ ?)+$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.')));
$emailaddress = new Zend_Form_Element_Text('emailaddress');
$emailaddress->setRequired(true);
$emailaddress->setAttrib('maxLength', 50);
$emailaddress->setLabel("Email");
$emailaddress->addFilter('StripTags');
$emailaddress->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
$emailaddress->addValidator("regex", true, array('pattern' => '/^(?!.*\\.{2})[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid email.')));
$emailaddress->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_users', 'field' => 'emailaddress', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '"')));
$emailaddress->getValidator('Db_NoRecordExists')->setMessage('Email already exists.');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $userfullname, $emailaddress, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例12: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'appraisalcategory');
$id = new Zend_Form_Element_Hidden('id');
$appraisalcategory = new Zend_Form_Element_Text("category_name");
$appraisalcategory->setLabel('Parameter');
$appraisalcategory->setAttrib('maxLength', 30);
$appraisalcategory->addFilter(new Zend_Filter_StringTrim());
$appraisalcategory->setRequired(true);
$appraisalcategory->addValidator('NotEmpty', false, array('messages' => 'Please enter parameter.'));
$appraisalcategory->addValidator("regex", true, array('pattern' => '/^[a-zA-Z0-9.\\- ?\',\\/#@$&*()!+]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid parameter.')));
$appraisalcategory->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_pa_category', 'field' => 'category_name', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" AND isactive=1')));
$appraisalcategory->getValidator('Db_NoRecordExists')->setMessage('Parameter name already exists.');
$description = new Zend_Form_Element_Textarea('description');
$description->setLabel("Description");
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $appraisalcategory, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例13: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', BASE_URL . 'payfrequency/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'payfrequency');
$id = new Zend_Form_Element_Hidden('id');
$freqtype = new Zend_Form_Element_Text('freqtype');
$freqtype->setAttrib('maxLength', 20);
$freqtype->setLabel("Pay Frequency");
$freqtype->setRequired(true);
$freqtype->addValidator('NotEmpty', false, array('messages' => 'Please enter pay frequency type.'));
$freqtype->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid pay frequency type.')));
$freqtype->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_payfrequency', 'field' => 'freqtype', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$freqtype->getValidator('Db_NoRecordExists')->setMessage('Pay frequency type already exists.');
$freqshortcode = new Zend_Form_Element_Text('freqcode');
$freqshortcode->setLabel("Short Code");
$freqshortcode->setAttrib('maxLength', 20);
$freqshortcode->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid pay frequency short code.')));
$freqshortcode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_payfrequency', 'field' => 'freqcode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
$freqshortcode->getValidator('Db_NoRecordExists')->setMessage('Pay frequency short code already exists.');
$description = new Zend_Form_Element_Textarea('freqdescription');
$description->setAttrib('rows', 10);
$description->setAttrib('cols', 50);
$description->setAttrib('maxlength', '200');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $freqtype, $freqshortcode, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例14: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'roles');
$id = new Zend_Form_Element_Hidden('id');
$rolename = new Zend_Form_Element_Text('rolename');
$rolename->setAttrib('maxLength', 50);
$rolename->setAttrib('title', 'Role name');
$rolename->addFilter(new Zend_Filter_StringTrim());
$rolename->setRequired(true);
$rolename->addValidator('NotEmpty', false, array('messages' => 'Please enter role name.'));
$rolename->addValidator("regex", true, array('pattern' => '/^[a-zA-Z0-9 ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid role name.')));
$rolename->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_roles', 'field' => 'rolename', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive!=0')));
$rolename->getValidator('Db_NoRecordExists')->setMessage('Role name already exists.');
$rolename->addValidators(array(array('StringLength', false, array('min' => 3, 'max' => 50, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Role name must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Role name must contain at least %min% characters.')))));
$roletype = new Zend_Form_Element_Text('roletype');
$roletype->setRequired(true);
$roletype->setAttrib('maxLength', 25);
$roletype->setAttrib('title', 'Role type');
$roletype->addFilter(new Zend_Filter_StringTrim());
$roletype->addValidator('NotEmpty', false, array('messages' => 'Please enter role type.'));
$roletype->addValidator("regex", true, array('pattern' => '/^[a-zA-Z]+?$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.')));
$roletype->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_roles', 'field' => 'roletype', 'exclude' => 'id != "' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive != 0')));
$roletype->getValidator('Db_NoRecordExists')->setMessage('Role type already exists.');
$roletype->addValidators(array(array('StringLength', false, array('min' => 3, 'max' => 25, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Role type must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Role type must contain at least %min% characters.')))));
$roledescription = new Zend_Form_Element_Textarea('roledescription');
$roledescription->setAttrib('rows', 10);
$roledescription->setAttrib('cols', 50);
$roledescription->setAttrib('maxlength', '100');
$roledescription->setAttrib('title', 'Role description');
$levelid = new Zend_Form_Element_Hidden('levelid');
$levelid->addFilter(new Zend_Filter_StringTrim());
$levelid->setRequired(true);
$levelid->addValidator('NotEmpty', false, array('messages' => 'Please select level.'));
$istimeActive = Zend_Controller_Front::getInstance()->getRequest()->getParam('istimeactive');
$prev_cnt = new Zend_Form_Element_Hidden('prev_cnt');
$prev_cnt->setRequired(true);
if ($istimeActive) {
$prev_cnt->addValidator('NotEmpty', false, array('messages' => 'Please select privileges other than time management.'));
} else {
$prev_cnt->addValidator('NotEmpty', false, array('messages' => 'Please select privileges.'));
}
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$url = "'roles/saveupdate/format/json'";
$dialogMsg = "''";
$toggleDivId = "''";
$jsFunction = "'redirecttocontroller(\\'roles\\');'";
$submit->setOptions(array('onclick' => "saveDetails({$url},{$dialogMsg},{$toggleDivId},{$jsFunction});"));
$this->addElements(array($id, $rolename, $roletype, $roledescription, $levelid, $submit, $prev_cnt));
$this->setElementDecorators(array('ViewHelper'));
}
示例15: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'creditcarddetails');
$id = new Zend_Form_Element_Hidden('id');
$user_id = new Zend_Form_Element_Hidden('user_id');
//Card Type....(only alphabets)
$cardType = new Zend_Form_Element_Text('card_type');
$cardType->addFilter(new Zend_Filter_StringTrim());
$cardType->setAttrib('maxLength', 50);
$cardType->addValidators(array(array('StringLength', false, array('min' => 2, 'max' => 50, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Card type must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Card type must contain at least %min% characters.')))));
$cardType->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.')))));
//Card Number....
$cardNum = new Zend_Form_Element_Text('card_number');
$cardNum->addFilters(array('StringTrim', 'StripTags'));
$cardNum->setAttrib("maxlength", 16);
$cardNum->addValidators(array(array('StringLength', false, array('min' => 16, 'max' => 16, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Card number must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Card number must contain at least %min% characters.')))));
$cardNum->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_empcreditcarddetails', 'field' => 'card_number', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '"')));
$cardNum->getValidator('Db_NoRecordExists')->setMessage('Card number already exists.');
$cardNum->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9]+$/i', 'messages' => array('regexNotMatch' => 'Please enter only numbers.')))));
//Name on the card .... (only Alphabets)
$nameoncard = new Zend_Form_Element_Text('nameoncard');
$nameoncard->addFilter(new Zend_Filter_StringTrim());
$nameoncard->setAttrib('maxLength', 50);
$nameoncard->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.')))));
// Card Expiration Date ....
$card_expired_date = new ZendX_JQuery_Form_Element_DatePicker('card_expiration');
$card_expired_date->setOptions(array('class' => 'brdr_none'));
$card_expired_date->setAttrib('readonly', 'true');
$card_expired_date->setAttrib('onfocus', 'this.blur()');
// Expiration Date should be greater than today's date...
$card_expired_date->addValidator(new sapp_DateGreaterThanToday());
//Card Code ...
$card_code = new Zend_Form_Element_Text('card_code');
$card_code->addFilter(new Zend_Filter_StringTrim());
$card_code->setAttrib('maxLength', 4);
$card_code->addValidators(array(array('StringLength', false, array('min' => 3, 'max' => 4, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Card code must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Card code must contain at least %min% characters.')))));
$card_code->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9]+$/i', 'messages' => array('regexNotMatch' => 'Please enter only numbers.')))));
//Card issued by....(company name)
$card_issuedBy = new Zend_Form_Element_Text('card_issuedby');
$card_issuedBy->addFilter(new Zend_Filter_StringTrim());
$card_issuedBy->setAttrib('maxLength', 50);
$card_issuedBy->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.')))));
// Form Submit .........
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $user_id, $cardType, $cardNum, $nameoncard, $card_expired_date, $card_issuedBy, $card_code, $submit));
$this->setElementDecorators(array('ViewHelper'));
$this->setElementDecorators(array('UiWidgetElement'), array('card_expiration'));
}