本文整理汇总了PHP中Zend_Form_Element_Text::addValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Text::addValidator方法的具体用法?PHP Zend_Form_Element_Text::addValidator怎么用?PHP Zend_Form_Element_Text::addValidator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Text
的用法示例。
在下文中一共展示了Zend_Form_Element_Text::addValidator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'holidaygroups');
$id = new Zend_Form_Element_Hidden('id');
$holidayname = new Zend_Form_Element_Text('holidayname');
$holidayname->setAttrib('maxLength', 20);
$holidayname->addFilter(new Zend_Filter_StringTrim());
$holidayname->setRequired(true);
$holidayname->addValidator('NotEmpty', false, array('messages' => 'Please enter holiday.'));
$holidayname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z0-9.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid holiday.')));
$groupid = new Zend_Form_Element_Multiselect('groupid');
$groupid->setAttrib('class', 'selectoption');
$groupid->setRegisterInArrayValidator(false);
$groupid->setRequired(true);
$groupid->addValidator('NotEmpty', false, array('messages' => 'Please select holiday group.'));
$holiday_date = new ZendX_JQuery_Form_Element_DatePicker('holidaydate');
$holiday_date->setAttrib('readonly', 'true');
$holiday_date->setAttrib('onfocus', 'this.blur()');
$holiday_date->setOptions(array('class' => 'brdr_none'));
$holiday_date->setRequired(true);
$holiday_date->addValidator('NotEmpty', false, array('messages' => 'Please select date.'));
$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, $holidayname, $groupid, $holiday_date, $description, $submit));
$this->setElementDecorators(array('ViewHelper'));
$this->setElementDecorators(array('UiWidgetElement'), array('holidaydate'));
}
示例2: init
/** Initialize this form. */
public function init()
{
$this->setName('oai_admin');
$this->setMethod('POST');
$csrf = new Midas_Form_Element_Hash('csrf');
$csrf->setSalt('YTVEA8QwsJqFaPfcnEugjKrM');
$csrf->setDecorators(array('ViewHelper'));
$repositoryName = new Zend_Form_Element_Text(OAI_REPOSITORY_NAME_KEY);
$repositoryName->setLabel('OAI Repository Name');
$repositoryName->setRequired(true);
$repositoryName->addValidator('NotEmpty', true);
$repositoryIdentifier = new Zend_Form_Element_Text(OAI_REPOSITORY_IDENTIFIER_KEY);
$repositoryIdentifier->setLabel('OAI Repository Identifier');
$repositoryIdentifier->setRequired(true);
$repositoryIdentifier->addValidator('NotEmpty', true);
$adminEmail = new Zend_Form_Element_Text(OAI_ADMIN_EMAIL_KEY);
$adminEmail->setLabel('Admin Email Address');
$adminEmail->setRequired(true);
$adminEmail->addValidator('NotEmpty', true);
$adminEmail->addValidator('EmailAddress', true);
$this->addDisplayGroup(array($repositoryName, $repositoryIdentifier, $adminEmail), 'global');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Save');
$this->addElements(array($csrf, $repositoryName, $repositoryIdentifier, $adminEmail, $submit));
}
示例3: 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'));
}
示例4: 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'));
}
示例5: __construct
/**
* @author code generate
* @return mixed
*/
public function __construct($option = array())
{
$classId = new Zend_Form_Element_Hidden('UserId');
$classId->setDecorators(array('ViewHelper'));
$this->addElement($classId);
$email = new Zend_Form_Element_Text('Email');
$email->setLabel('Email *');
$email->addFilter('StringTrim');
$email->setRequired(true);
$email->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group'))));
$email->addValidator(new Zend_Validate_Db_NoRecordExists("Users", "Email"));
$email->addValidator('EmailAddress', true);
$email->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Email không phù hợp")));
$this->addElement($email);
$save = new Zend_Form_Element_Submit('Save');
$save->setLabel('Đăng ký');
$save->setAttrib('class', 'btn btn-primary');
$save->setDecorators(array('ViewHelper'));
$this->addElement($save);
$reset = new Zend_Form_Element_Reset('Reset');
$reset->setLabel('Làm lại');
$reset->setAttrib('class', 'btn btn-primary');
$reset->setDecorators(array('ViewHelper'));
$this->addElement($reset);
}
示例6: init
public function init()
{
$this->setName('registerForm');
$this->setMethod('post');
$this->setAction('/user/register/');
$user = new Zend_Form_Element_Text('user');
$user->setLabel('Username');
$user->setRequired(true);
$user->addValidator('Alnum', false);
$user->addValidator('StringLength', true, array(3, 30));
//$user->addValidator('Db_NoRecordExists', true, array('user', 'user') );
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password');
$password->setRenderPassword(true);
$password->setRequired(true);
$password->addValidator('StringLength', true, array(5, 50));
$name = new Zend_Form_Element_Text('name');
$name->setLabel('Full Name');
$name->setRequired(true);
$name->addValidator('StringLength', true, array(3, 128));
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email');
$email->setRequired(true);
$email->addValidator('EmailAddress', true);
$email->addValidator('StringLength', true, array(3, 128));
$submit = new Zend_Form_Element_Submit('register');
$submit->setLabel('Register');
$hash = new Zend_Form_Element_Hash('hash');
$this->setElements(array($user, $password, $name, $email, $submit, $hash));
}
示例7: 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'));
}
示例8: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'empleaves');
$id = new Zend_Form_Element_Hidden('id');
$userid = new Zend_Form_Element_Hidden('user_id');
$emp_leave_limit = new Zend_Form_Element_Text('leave_limit');
$emp_leave_limit->setAttrib('maxLength', 3);
$emp_leave_limit->addFilter(new Zend_Filter_StringTrim());
$emp_leave_limit->setRequired(true);
$emp_leave_limit->addValidator('NotEmpty', false, array('messages' => 'Please enter leave limit for current year.'));
$emp_leave_limit->addValidator("regex", true, array('pattern' => '/^(\\-?[1-9]|\\-?[1-9][0-9])$/', 'messages' => array('regexNotMatch' => 'Leave limit must be in the range of 0 to 100.')));
$used_leaves = new Zend_Form_Element_Text('used_leaves');
$used_leaves->setAttrib('maxLength', 3);
$used_leaves->setAttrib('readonly', 'true');
$used_leaves->setAttrib('onfocus', 'this.blur()');
$alloted_year = new Zend_Form_Element_Text('alloted_year');
$alloted_year->setAttrib('maxLength', 4);
$alloted_year->setAttrib('readonly', 'true');
$alloted_year->setAttrib('onfocus', 'this.blur()');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$submitbutton = new Zend_Form_Element_Button('submitbutton');
$submitbutton->setAttrib('id', 'submitbuttons');
$submitbutton->setLabel('Save');
$this->addElements(array($id, $userid, $emp_leave_limit, $used_leaves, $alloted_year, $submit, $submitbutton));
$this->setElementDecorators(array('ViewHelper'));
}
示例9: init
public function init()
{
$this->setMethod('post')->setAttrib('id', 'frmVenta')->setAttrib('style', 'width: 300px;margin:auto;');
// Producto
$e = new Zend_Form_Element_Select('id_producto');
$e->setLabel('Producto');
$e->setRequired();
$_producto = new Application_Model_Producto();
$e->addMultiOption(-1, '--Producto--');
$e->addMultiOptions($_producto->getComboValues());
$e->addValidator(new Zend_Validate_InArray($_producto->getComboValidValues()));
$this->addElement($e);
// Cantidad
$e = new Zend_Form_Element_Text('cantidad');
$e->setLabel('Cantidad');
$e->setRequired();
$e->addValidator(new Zend_Validate_Int(new Zend_Locale('US')));
$e->addValidator(new Zend_Validate_GreaterThan(0));
$e->addValidator(new Zend_Validate_LessThan(100));
$this->addElement($e);
// AddVentaDetalles
$e = new Zend_Form_Element_Hidden('is_detalle');
$e->setValue(true);
$e->setRequired();
$this->addElement($e);
//Submit
$e = new Zend_Form_Element_Submit('submit');
$e->setLabel('Agregar');
$this->addElement($e);
}
示例10: init
/** Initialize this form. */
public function init()
{
$this->setName('sizequota_admin');
$this->setMethod('POST');
$csrf = new Midas_Form_Element_Hash('csrf');
$csrf->setSalt('f6g5NzqPWAunkSykbBpmTmpH');
$csrf->setDecorators(array('ViewHelper'));
$defaultUserQuotaValue = new Zend_Form_Element_Text(MIDAS_SIZEQUOTA_DEFAULT_USER_QUOTA_VALUE_KEY);
$defaultUserQuotaValue->setLabel('Default User Quota');
$defaultUserQuotaValue->addValidator('Float', true);
$defaultUserQuotaValue->addValidator('Between', true, array('min' => 0, 'max' => PHP_INT_MAX));
$defaultUserQuotaUnit = new Zend_Form_Element_Select(MIDAS_SIZEQUOTA_DEFAULT_USER_QUOTA_UNIT_KEY);
$defaultUserQuotaUnit->setLabel('Unit');
$defaultUserQuotaUnit->setRequired(true);
$defaultUserQuotaUnit->addValidator('NotEmpty', true);
$defaultUserQuotaUnit->addMultiOptions(array(MIDAS_SIZE_B => 'B', MIDAS_SIZE_KB => 'KB', MIDAS_SIZE_MB => 'MB', MIDAS_SIZE_GB => 'GB', MIDAS_SIZE_TB => 'TB'));
$this->addDisplayGroup(array($defaultUserQuotaValue, $defaultUserQuotaUnit), 'default_user_quota');
$defaultCommunityQuotaValue = new Zend_Form_Element_Text(MIDAS_SIZEQUOTA_DEFAULT_COMMUNITY_QUOTA_VALUE_KEY);
$defaultCommunityQuotaValue->setLabel('Default Community Quota');
$defaultCommunityQuotaValue->addValidator('Float', true);
$defaultCommunityQuotaValue->addValidator('Between', true, array('min' => 0, 'max' => PHP_INT_MAX));
$defaultCommunityQuotaUnit = new Zend_Form_Element_Select(MIDAS_SIZEQUOTA_DEFAULT_COMMUNITY_QUOTA_UNIT_KEY);
$defaultCommunityQuotaUnit->setLabel('Unit');
$defaultCommunityQuotaUnit->setRequired(true);
$defaultCommunityQuotaUnit->addValidator('NotEmpty', true);
$defaultCommunityQuotaUnit->addMultiOptions(array(MIDAS_SIZE_B => 'B', MIDAS_SIZE_KB => 'KB', MIDAS_SIZE_MB => 'MB', MIDAS_SIZE_GB => 'GB', MIDAS_SIZE_TB => 'TB'));
$this->addDisplayGroup(array($defaultCommunityQuotaValue, $defaultCommunityQuotaUnit), 'default_community_quota');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Save');
$this->addElements(array($csrf, $defaultUserQuotaValue, $defaultUserQuotaUnit, $defaultCommunityQuotaValue, $defaultCommunityQuotaUnit, $submit));
}
示例11: init
public function init()
{
$this->setMethod('post');
$this->setAction(DOMAIN . 'index/editforgotpassword');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'forgotpassword');
$id = new Zend_Form_Element_Hidden('id');
$username = new Zend_Form_Element_Text('emailaddress');
$username->setAttrib('class', 'email-status');
$username->setLabel('Email Address:');
$username->setRequired(true);
$username->addFilter('StripTags');
$username->addFilter('StringTrim');
$username->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
$username->addValidator('EmailAddress');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('SEND');
$url = "'default/index/editforgotpassword/format/json'";
$dialogMsg = "''";
$toggleDivId = "''";
$jsFunction = "''";
$submit->setOptions(array('onclick' => "saveDetails({$url},{$dialogMsg},{$toggleDivId},{$jsFunction});"));
$this->addElements(array($id, $username, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例12: init
/**
* Creates the form to log in.
* @see Zend_Form::init()
*/
public function init()
{
$this->setMethod('post');
$this->setAction("/auth/login/");
$usernameElement = new Zend_Form_Element_Text('username');
$usernameElement->setLabel("Benutzername");
$usernameElement->addValidator('regex', false, array('/^[a-z0-9]/i'));
$usernameElement->addValidator('stringLength', false, array(2, 64));
$usernameElement->setAttrib('maxLength', 64);
$usernameElement->setRequired(true);
$passwordElement = new Zend_Form_Element_Password('password');
$passwordElement->setLabel("Passwort");
$passwordElement->addValidator('regex', false, array('/^[a-z0-9]/i'));
$passwordElement->addValidator('stringLength', false, array(8, 32));
$passwordElement->setAttrib('maxLength', 32);
$passwordElement->setRequired(true);
$submitElement = new Zend_Form_Element_Submit('submit');
$submitElement->setLabel('Anmelden');
$submitElement->setIgnore(true);
$submitElement->setAttrib('class', 'submit');
$submitElement->removeDecorator('DtDdWrapper');
$this->addElements(array($usernameElement, $passwordElement));
$this->addDisplayGroup(array('username', 'password'), 'credentialGroup', array('legend' => 'Zugangsdaten'));
$this->addElements(array($submitElement));
}
示例13: init
/** Initialize this form. */
public function init()
{
$this->setName('sizequota_folder');
$this->setAction($this->getView()->baseUrl('/sizequota/folder/submit'));
$this->setMethod('POST');
$csrf = new Midas_Form_Element_Hash('csrf');
$csrf->setSalt('FDXuUnSDkUE7Anh2kqgca8zv');
$csrf->setDecorators(array('ViewHelper'));
$folderId = new Zend_Form_Element_Hidden('folder_id');
$folderId->setDecorators(array('ViewHelper'));
$useDefaultFolderQuota = new Zend_Form_Element_Checkbox('use_default_folder_quota');
$useDefaultFolderQuota->setLabel('Use Default Folder Quota');
$folderQuotaValue = new Zend_Form_Element_Text('folder_quota_value');
$folderQuotaValue->setLabel('Quota');
$folderQuotaValue->addValidator('Float', true);
$folderQuotaValue->addValidator('Between', true, array('min' => 0, 'max' => PHP_INT_MAX));
$folderQuotaUnit = new Zend_Form_Element_Select('folder_quota_unit');
$folderQuotaUnit->setLabel('Unit');
$folderQuotaUnit->setRequired(true);
$folderQuotaUnit->addValidator('NotEmpty', true);
$folderQuotaUnit->addMultiOptions(array(MIDAS_SIZE_B => 'B', MIDAS_SIZE_KB => 'KB', MIDAS_SIZE_MB => 'MB', MIDAS_SIZE_GB => 'GB', MIDAS_SIZE_TB => 'TB'));
$this->addDisplayGroup(array($useDefaultFolderQuota, $folderQuotaValue, $folderQuotaUnit), 'global');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Save');
$this->addElements(array($csrf, $folderId, $useDefaultFolderQuota, $folderQuotaValue, $folderQuotaUnit, $submit));
}
示例14: init
public function init()
{
$this->setMethod('post');
$this->setAction('/main/new');
$this->setAttrib('id', 'newRoute');
$note = new Zend_Form_Element_Note('title', array('value' => '<h2 id="titleProductDetails">Create a New Route</h2>'));
$intermed = new Zend_Form_Element_Hidden('intermed');
$intermed->setAttrib('readonly', 'readonly');
$intermed->addFilter('StripTags');
$intermed->addFilter('HtmlEntities');
$intermed->addFilter('StringTrim');
$start = new Zend_Form_Element_Text('startForm');
$start->setLabel('Starting Point*');
$start->setAttrib('autocomplete', 'off');
$start->addFilter('StripTags');
$start->addFilter('HtmlEntities');
$start->setAttrib('class', 'form-control');
$start->addFilter('StringTrim');
$start->setRequired(true)->addErrorMessage('Start Location Required');
// $start->addValidator('Regex', true, array('/^[a-zA-Z0-9.,:-\s]*$/'))->addErrorMessage('Invalid characters used');
// $start->addValidator('StringLength', true, array(0, 255))->addErrorMessage('Required Field');
$end = new Zend_Form_Element_Text('endForm');
$end->setLabel('Destination*');
$end->setAttrib('autocomplete', 'off');
$end->addFilter('StripTags');
$end->setAttrib('class', 'form-control');
$end->addFilter('HtmlEntities');
$end->addFilter('StringTrim');
$end->setRequired(true)->addErrorMessage('Destination Required');
// $end->addValidator('StringLength', true, array(0, 255))->addErrorMessage('Required Field');
$routeDate = new Zend_Form_Element_Text('routeDate');
$routeDate->setAttrib('autocomplete', 'off');
$routeDate->setAttrib('readonly', 'readonly');
$routeDate->setAttrib('maxlength', '10');
$routeDate->setAttrib('class', 'form-control');
$routeDate->setLabel('Date of Journey' . '*');
$routeDate->addFilter('StripTags');
$routeDate->addFilter('HtmlEntities');
$routeDate->addFilter('StringTrim');
$routeDate->setRequired(true)->addErrorMessage('Date Required');
$routeDate->addValidator('Regex', true, array('/^[0-9.\\s]*$/'))->addErrorMessage('Invalid characters used');
$routeDate->addValidator('StringLength', true, array(10, 10))->addErrorMessage('Required Field');
$passangers = new Zend_Form_Element_Select('passangers');
$passangers->setLabel('No of Passangers*');
$passangers->setAttrib('autocomplete', 'off');
$passangers->setAttrib('class', 'form-control');
$passangers->addFilter('StripTags');
$passangers->addFilter('HtmlEntities');
$passangers->addFilter('StringTrim');
$passangers->setRequired(true)->addErrorMessage('Password Required');
$passangers->setMultiOptions(array('1' => '1 Passanger', '2' => '2 Passangers', '3' => '3 Passangers', '4' => '4 Passangers', '5' => '5 Passangers', '6' => '6 Passangers'));
$submit = new Zend_Form_Element_Submit('newRoute');
$submit->setLabel('New Route');
$submit->setAttrib('class', 'btn btn-info');
$submit->setAttrib('style', 'margin-top:20px');
$this->addElements(array($note, $intermed, $start, $end, $passangers, $routeDate, $submit));
$this->setElementDecorators(array('ViewHelper', 'Label', 'Errors'));
$submit->setDecorators(array('ViewHelper'));
$this->setDecorators(array('FormElements', 'Form', array('HtmlTag', array('tag' => 'div', 'id' => 'newRouteFormContainer'))));
}
示例15: init
public function init()
{
$this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast.phtml'))));
$relativeDates = array();
$relativeDates[""] = "";
for ($i = 0; $i <= 30; $i++) {
$relativeDates["{$i} days"] = "+{$i} " . _("days");
}
for ($i = 1; $i <= 10; $i++) {
$select = new Zend_Form_Element_Select("add_show_rebroadcast_date_{$i}");
$select->setAttrib('class', 'input_select');
$select->setMultiOptions($relativeDates);
$select->setRequired(false);
$select->setDecorators(array('ViewHelper'));
$this->addElement($select);
$text = new Zend_Form_Element_Text("add_show_rebroadcast_time_{$i}");
$text->setAttrib('class', 'input_text');
$text->addFilter('StringTrim');
$text->addValidator('date', false, array('HH:mm'));
$text->addValidator('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')));
$text->setRequired(false);
$text->setDecorators(array('ViewHelper'));
$this->addElement($text);
}
}