本文整理汇总了PHP中Zend_Form_Element_Text::setValidators方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Text::setValidators方法的具体用法?PHP Zend_Form_Element_Text::setValidators怎么用?PHP Zend_Form_Element_Text::setValidators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Text
的用法示例。
在下文中一共展示了Zend_Form_Element_Text::setValidators方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
$this->setDecorators(array('PrepareElements', array('ViewScript', array('viewScript' => 'form/edit-history-item.phtml'))));
/*
$instance = new Zend_Form_Element_Select("instance_id");
$instance->setLabel(_("Choose Show Instance"));
$instance->setMultiOptions(array("0" => "-----------"));
$instance->setValue(0);
$instance->setDecorators(array('ViewHelper'));
$this->addElement($instance);
*/
$starts = new Zend_Form_Element_Text(self::ID_PREFIX . 'starts');
$starts->setValidators(array(new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)));
$starts->setAttrib('class', self::TEXT_INPUT_CLASS . " datepicker");
$starts->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
$starts->addFilter('StringTrim');
$starts->setLabel(_('Start Time'));
$starts->setDecorators(array('ViewHelper'));
$starts->setRequired(true);
$this->addElement($starts);
$ends = new Zend_Form_Element_Text(self::ID_PREFIX . 'ends');
$ends->setValidators(array(new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)));
$ends->setAttrib('class', self::TEXT_INPUT_CLASS . " datepicker");
$ends->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
$ends->addFilter('StringTrim');
$ends->setLabel(_('End Time'));
$ends->setDecorators(array('ViewHelper'));
//$ends->setRequired(true);
$this->addElement($ends);
}
示例2: createMigrateForm
/** Main form */
public function createMigrateForm($assetstores)
{
// Setup the form
$form = new Zend_Form();
$form->setAction('migratemidas2');
$form->setName('migrateForm');
$form->setMethod('post');
$form->setAttrib('class', 'migrateForm');
// Input directory
$midas2_hostname = new Zend_Form_Element_Text('midas2_hostname', array('label' => $this->t('MIDAS2 Hostname'), 'size' => 60, 'value' => 'localhost'));
$midas2_hostname->setRequired(true);
$form->addElement($midas2_hostname);
$midas2_port = new Zend_Form_Element_Text('midas2_port', array('label' => $this->t('MIDAS2 Port'), 'size' => 4, 'value' => '5432'));
$midas2_port->setRequired(true);
$midas2_port->setValidators(array(new Zend_Validate_Digits()));
$form->addElement($midas2_port);
$midas2_user = new Zend_Form_Element_Text('midas2_user', array('label' => $this->t('MIDAS2 User'), 'size' => 60, 'value' => 'midas'));
$midas2_user->setRequired(true);
$form->addElement($midas2_user);
$midas2_password = new Zend_Form_Element_Password('midas2_password', array('label' => $this->t('MIDAS2 Password'), 'size' => 60, 'value' => 'midas'));
$midas2_password->setRequired(true);
$form->addElement($midas2_password);
$midas2_database = new Zend_Form_Element_Text('midas2_database', array('label' => $this->t('MIDAS2 Database'), ' size' => 60, 'value' => 'midas'));
$midas2_database->setRequired(true);
$form->addElement($midas2_database);
$midas2_assetstore = new Zend_Form_Element_Text('midas2_assetstore', array('label' => $this->t('MIDAS2 Assetstore Path'), 'size' => 60, 'value' => 'C:/xampp/midas/assetstore'));
$midas2_assetstore->setRequired(true);
$form->addElement($midas2_assetstore);
// Button to select the directory on the server
$midas2_assetstore_button = new Zend_Form_Element_Button('midas2_assetstore_button', $this->t('Choose'));
$midas2_assetstore_button->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
$form->addElement($midas2_assetstore_button);
// Assetstore
$assetstoredisplay = array();
$assetstoredisplay[0] = $this->t('Choose one...');
// Initialize with the first type (MIDAS)
foreach ($assetstores as $assetstore) {
if ($assetstore->getType() == 0) {
$assetstoredisplay[$assetstore->getAssetstoreId()] = $assetstore->getName();
}
}
$assetstore = new Zend_Form_Element_Select('assetstore');
$assetstore->setLabel($this->t('MIDAS3 Assetstore'));
$assetstore->setMultiOptions($assetstoredisplay);
$assetstore->setDescription(' <a class="load-newassetstore" href="#newassetstore-form" rel="#newassetstore-form" title="' . $this->t('Add a new assetstore') . '"> ' . $this->t('Add a new assetstore') . '</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
$assetstore->setRequired(true);
$assetstore->setValidators(array(new Zend_Validate_GreaterThan(array('min' => 0))));
$assetstore->setRegisterInArrayValidator(false);
// This array is dynamic so we disable the validator
$form->addElement($assetstore);
// Submit
$submit = new Zend_Form_Element_Button('migratesubmit', $this->t('Migrate'));
$form->addElement($submit);
return $form;
}
示例3: init
public function init()
{
// profissional_beleza_nome
$profissional_beleza_nome = new Zend_Form_Element_Text("profissional_beleza_nome");
$profissional_beleza_nome->setLabel("Nome: ");
$profissional_beleza_nome->setAttribs(array('class' => 'form-control'));
$profissional_beleza_nome->setRequired();
$profissional_beleza_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators);
// profissional_beleza_email
$profissional_beleza_email = new Zend_Form_Element_Text("profissional_beleza_email");
$profissional_beleza_email->setLabel("E-mail: ");
$profissional_beleza_email->setValidators(array('EmailAddress'));
$profissional_beleza_email->addValidator(new App_Validate_ProfissionalBeleza());
$profissional_beleza_email->setAttribs(array('class' => 'form-control'));
$profissional_beleza_email->setRequired();
$profissional_beleza_email->setDecorators(App_Forms_Decorators::$simpleElementDecorators);
/**
* profisional_beleza_sexo
*/
$profissional_beleza_sexo = new Zend_Form_Element_Radio("profissional_beleza_sexo");
$profissional_beleza_sexo->setLabel("Sexo:");
$profissional_beleza_sexo->setRequired();
$profissional_beleza_sexo->setDecorators(App_Forms_Decorators::$checkboxElementDecorators);
$profissional_beleza_sexo->setMultiOptions(array('M' => ' Masculino', 'F' => ' Feminino'));
// profissional_beleza_avatar
$profissional_beleza_avatar = new Zend_Form_Element_File("profissional_beleza_avatar");
$profissional_beleza_avatar->setLabel(" \n Foto: \n ");
$profissional_beleza_avatar->addDecorators(App_Forms_Decorators::$ElementDecoratorFile);
$profissional_beleza_avatar->setAttribs(array('class' => 'filestyle', 'data-buttonText' => 'Selecione a foto', 'data-iconName' => 'fa fa-user'));
$profissional_beleza_avatar->setRequired();
$profissional_beleza_avatar->setDestination(Zend_Registry::get('config')->profissional->avatar->path);
$profissional_beleza_avatar->addValidators(array(array('Extension', false, 'jpg,jpeg,png')));
$profissional_beleza_avatar->addFilter(new Skoch_Filter_File_Resize(array('width' => 160, 'keepRatio' => true)));
// especialidade_id
$especialidade_id = new Zend_Form_Element_MultiCheckbox("especialidade_id");
$especialidade_id->setLabel("Selecione as especialidades: ");
$especialidade_id->setAttribs(array('class' => ''));
$especialidade_id->setRequired();
$especialidade_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators);
$especialidade_id->setSeparator(' ');
$especialidade_id->setMultiOptions($this->getEspecialidades());
// addElements
$this->addElements(array($profissional_beleza_nome, $profissional_beleza_email, $profissional_beleza_sexo, $profissional_beleza_avatar, $especialidade_id));
parent::init();
}
示例4: __construct
public function __construct()
{
parent::__construct();
$this->addElement('text', 'username', array('label' => 'Owner:', 'disabled' => 'disabled'));
$this->addElement('text', AttributeDescriptor::COL_NAME, array('label' => 'name:', 'required' => true, 'validators' => array(new Zend_Validate_Alnum(true))));
$this->addElement(new Default_Form_Element_ValuelistSelect(604, AttributeDescriptor::COL_UNIT, array('label' => 'unit:', 'validator' => 'int')));
$this->addElement('textarea', AttributeDescriptor::COL_DESCRIPTION, array('label' => 'description:', 'rows' => '4', 'cols' => '40'));
$this->addElement('text', AttributeDescriptor::COL_DEFAULT, array('label' => 'default value:'));
$this->addElement('checkbox', AttributeDescriptor::COL_REQUIRED, array('label' => 'is required:'));
$this->addElement('checkbox', AttributeDescriptor::COL_IS_STANDARD, array('label' => 'is standard:'));
$this->addElement('checkbox', AttributeDescriptor::COL_ACTIVE, array('label' => 'active:'));
$datatypes = new Zend_Form_Element_Select(AttributeDescriptor::COL_DATA_TYPE);
$datatypes->setLabel('data type:');
$datatypes->addMultiOptions(array('Please select' => null, 'string' => 'string', 'decimal' => 'decimal', 'integer' => 'integer', 'boolaen' => 'boolean', 'date' => 'date', 'time' => 'time', 'datetime' => 'datetime'));
$datatypes->setRequired(true);
$this->addElement($datatypes);
$formtypes = new Zend_Form_Element_Select(AttributeDescriptor::COL_FORM_TYPE);
$formtypes->setLabel('form type:');
$formtypes->addMultiOptions(array('Please select' => null, 'checkbox' => 'checkbox', 'textarea' => 'textarea', 'multicheckbox' => 'multicheckbox', 'multiselect' => 'multiSelect', 'radio' => 'radiobuttons', 'select' => 'select', 'text' => 'textbox'));
$formtypes->setRequired(true);
$this->addElement($formtypes);
$this->addElement('checkbox', AttributeDescriptor::COL_VALUE_LIST, array('label' => 'has valuelist:'));
$sequence = new Zend_Form_Element_Text(AttributeDescriptor::COL_SEQUENCE);
$lastSequenceFish = $this->getLastSequence('fish');
$lastSequenceImage = $this->getLastSequence('image');
$sequence->setLabel('sequence (last sequence fish:' . $lastSequenceFish . ' last sequence image:' . $lastSequenceImage . '):');
$sequence->setRequired(true);
$sequence->setValidators(array(new Zend_Validate_Int(), new Zend_Validate_GreaterThan(0)));
$this->addElement($sequence);
$this->addElement('checkbox', AttributeDescriptor::COL_MULTIPLE, array('label' => 'is multiple:'));
$this->addElement('checkbox', AttributeDescriptor::COL_SHOW_IN_LIST, array('label' => 'show in list:'));
$group = new Zend_Form_Element_Select(AttributeDescriptor::COL_GROUP);
$group->setLabel('attribute group:');
$group->addMultiOptions(array('Please select' => null, 'image' => 'image', 'fish' => 'fish', 'system' => 'system'));
$group->setRequired(true);
$this->addElement($group);
//render as html table and add the submit button
$this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'login_form', 'border' => 'solid')), array('Description', array('placement' => 'prepend')), 'Form'));
$this->setElementDecorators(array('ViewHelper', 'Errors', array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')), array('Label', array('tag' => 'td')), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))));
$this->addElement('submit', 'submit', array('required' => false, 'ignore' => true, 'label' => 'save'));
$this->submit->setDecorators(array(array('decorator' => 'ViewHelper', 'options' => array('helper' => 'formSubmit')), array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td', 'colspan' => 2)), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))));
// hidden elements
$this->addElement('hidden', AttributeDescriptor::COL_ID);
$this->addElement('hidden', AttributeDescriptor::COL_USER_ID);
}