本文整理汇总了PHP中Zend_Form_Element_Select::setValidators方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Select::setValidators方法的具体用法?PHP Zend_Form_Element_Select::setValidators怎么用?PHP Zend_Form_Element_Select::setValidators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Select
的用法示例。
在下文中一共展示了Zend_Form_Element_Select::setValidators方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: createImportForm
/** Main form */
public function createImportForm($assetstores)
{
// Setup the form
$form = new Zend_Form();
$form->setAction('import/import');
$form->setName('importForm');
$form->setMethod('post');
$form->setAttrib('class', 'importForm');
/** @var RandomComponent $randomComponent */
$randomComponent = MidasLoader::loadComponent('Random');
// Hidden upload id
$uploadId = new Zend_Form_Element_Hidden('uploadid', array('value' => $randomComponent->generateInt()));
$uploadId->setDecorators(array('ViewHelper', array('HtmlTag', array('style' => 'display:none')), array('Label', array('style' => 'display:none'))));
$form->addElement($uploadId);
// Input directory
$inputDirectory = new Zend_Form_Element_Text('inputdirectory', array('label' => $this->t('Directory on the server'), 'id' => 'inputdirectory', 'size' => 60));
$inputDirectory->setRequired(true);
$form->addElement($inputDirectory);
// Button to select the directory on the server
$inputDirectoryButton = new Zend_Form_Element_Button('inputdirectorybutton', $this->t('Choose'));
$inputDirectoryButton->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
$form->addElement($inputDirectoryButton);
// Select the assetstore type
$assetstoretypes = array();
$assetstoretypes[MIDAS_ASSETSTORE_LOCAL] = $this->t('Copy data on this server');
// manage by MIDAS
$assetstoretypes[MIDAS_ASSETSTORE_REMOTE] = $this->t('Link data from its current location');
// link the data
$assetstoretype = new Zend_Form_Element_Select('importassetstoretype');
$assetstoretype->setLabel($this->t('Storage type'));
$assetstoretype->setMultiOptions($assetstoretypes);
$assetstoretype->setAttrib('onChange', 'assetstoretypeChanged()');
$form->addElement($assetstoretype);
// 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('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);
// Import empty directories
$emptydirs = new Zend_Form_Element_Checkbox('importemptydirectories');
$emptydirs->setLabel($this->t('Import empty directories'))->setChecked(true);
$form->addElement($emptydirs);
// Where to import the data
$importFolder = new Zend_Form_Element_Text('importFolder', array('label' => $this->t('Folder Id'), 'id' => 'importFolder', 'size' => 3, 'value' => 1));
$importFolder->setRequired(true);
$form->addElement($importFolder);
// Hidden filed to pass the translation of the stop import
$stopimport = new Zend_Form_Element_Hidden('importstop', array('value' => $this->t('Stop import')));
$stopimport->setDecorators(array('ViewHelper', array('HtmlTag', array()), array('Label', array()), 'Errors'));
$form->addElement($stopimport);
// Submit
$submit = new Zend_Form_Element_Button('importsubmit', $this->t('Import data'));
$form->addElement($submit);
return $form;
}