本文整理汇总了PHP中Zend_Validate_NotEmpty类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_NotEmpty类的具体用法?PHP Zend_Validate_NotEmpty怎么用?PHP Zend_Validate_NotEmpty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Validate_NotEmpty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
// Verifica se o campo select esta com o valor null
$required = new Zend_Validate_NotEmpty();
$required->setType($required->getType() | Zend_Validate_NotEmpty::STRING | Zend_Validate_NotEmpty::ZERO);
$data_now = new Zend_Date();
$options_sim_nao = array('Não', 'Sim');
$options_categoria = array('Alto padrão' => 'Alto padrão', 'Médio padrão' => 'Médio padrão', 'Econômico' => 'Econômico');
$options_empty = array('');
$options_tipo = array('0' => '--- Selecione uma opção ---', '1' => 'Apartamento', '2' => 'Casa');
$this->addElement('text', 'nome', array('label' => 'Nome', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(12)));
$this->addElement('text', 'logradouro', array('label' => 'Logradouro', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('select', 'categoria', array('label' => 'Categoria', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_categoria, 'decorators' => $this->setColSize(3)));
$this->addElement('select', 'tipo', array('label' => 'Tipo de empreendimento', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_tipo, 'decorators' => $this->setColSize(3), 'validators' => array($required)));
$this->addElement('select', 'cad_corretagem', array('label' => 'Cad. Corretagem Mediação', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_sim_nao, 'decorators' => $this->setColSize(3)));
$this->addElement('text', 'incorporadora', array('label' => 'Proprietario(a)', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('hidden', 'unidades', array('label' => '', 'decorators' => $this->setColSize(1)));
$this->addElement('hidden', 'created_user_id', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(1)));
$this->addElement('hidden', 'last_user_id', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(1)));
$this->addElement('hidden', 'locked', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(1)));
$this->addElement('hidden', 'locked_by', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(1)));
$this->addElement('submit', 'Enviar', array('label' => 'Enviar', 'ignore' => 'true', 'class' => 'btn btn-success pull-right', 'decorators' => $this->setColSize(12, false)));
$this->setDecorators(array('FormElements', array(array('in' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row')), 'Form', array('HtmlTag', array('tag' => 'div', 'class' => 'panel panel-body panel-default'))));
$this->setAttrib('class', 'form');
$this->setAttrib('id', 'empreendimento');
$this->setMethod('post');
}
示例2: __construct
public function __construct($data, $sodu, $tongno)
{
$val = new Zend_Validate_NotEmpty();
$num = new Zend_Validate_Digits();
$date = new Zend_Validate_Date(array('format' => 'dd/MM/yyyy'));
if ($val->isValid($data['tenhoadon']) == false) {
$this->messages[] = "Tên Hóa Đơn không được trống";
}
if ($val->isValid($data['tienthanhtoan']) == false) {
$this->messages[] = "Tiền thanh toán được trống";
} else {
if ($num->isValid($data['tienthanhtoan']) == false) {
$this->messages[] = "Tiền thanh toán phải là số";
} else {
if ($data['tienthanhtoan'] > $sodu) {
$this->messages[] = "Tiền thanh toán phải nhỏ hơn số dư";
} else {
if ($data['tienthanhtoan'] > $tongno) {
$this->messages[] = "Tiền thanh toán không lớn hơn số nợ";
} else {
if ($data['tienthanhtoan'] < 0) {
$this->messages[] = "Tiền thanh toán phải là số dương";
}
}
}
}
}
if ($date->isValid($data['ngaythanhtoan']) == false) {
$this->messages[] = "Ngày thanh toán không đúng";
}
}
示例3: __construct
public function __construct($data)
{
$val = new Zend_Validate_NotEmpty();
$num = new Zend_Validate_Digits();
if ($val->isValid($data['ten']) == false) {
$this->messages[] = "Tên nhà cung cấp không được trống";
}
if ($num->isValid($data['sdt']) == false) {
$this->messages[] = "Số điện thoại phải là số";
}
if ($val->isValid($data['sdt']) == false) {
$this->messages[] = "Số điện thoại không được trống";
}
if ($num->isValid($data['fax']) == false) {
$this->messages[] = "Số fax phải là số";
}
if ($val->isValid($data['fax']) == false) {
$this->messages[] = "Số fax không được trống";
}
if (array_key_exists('no', $data)) {
if ($num->isValid($data['no']) == false) {
$this->messages[] = "Nợ phải là số";
}
if ($val->isValid($data['no']) == false) {
$this->messages[] = "Nợ không được trống";
}
}
}
示例4: init
public function init()
{
/* Form Elements & Other Definitions Here ... */
$element = new Zend_Form_Element_Text('login');
$element->setLabel('Login')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le login est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$validator = new Zend_Validate_StringLength();
$validator->setMax(40);
$element->addValidator($validator);
$filter = new Zend_Filter_StringTrim();
$element->addFilter($filter);
$this->addElement($element);
$element = new Zend_Form_Element_Password('password');
$element->setLabel('Mot de passe')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le mot de passe est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$validator = new Zend_Validate_StringLength();
$validator->setMax(40);
$element->addValidator($validator);
$filter = new Zend_Filter_StringTrim();
$element->addFilter($filter);
$this->addElement($element);
}
示例5: init
public function init()
{
// Verifica se o campo select esta com o valor null
$required = new Zend_Validate_NotEmpty();
$required->setType($required->getType() | Zend_Validate_NotEmpty::STRING | Zend_Validate_NotEmpty::ZERO);
$data_now = new Zend_Date();
$options_estado_civil = array('-- Selecione --', 'casado' => 'Casado', 'solteiro' => 'Solteiro', 'divorciado' => 'Divorciado', 'viuvo' => 'Viuvo');
$options_empty = array('-- Selecione --');
$options_meio_comunicacao = array('-- Selecione --', 'Telefone' => 'Telefone', 'Tv' => 'TV', 'Local' => 'Pass. no Local', 'Radio' => 'Rádio', 'Faixas' => 'Faixas', 'Email' => 'Email', 'Panfletagem' => 'Panfletagem', 'Mala direta' => 'Mala direta', 'Indicação' => 'Indicação', 'Internet' => 'Internet', 'Jornal' => 'Jornal', 'Outdoor' => 'Outdoor', 'Outros' => 'Outros');
$options_renda = array('-- Selecione --', 'formal' => 'Formal', 'informal' => 'Informal', 'mista' => 'Mista');
$options_sim_nao = array('Não', 'Sim');
$this->addElement('hidden', 'data', array('value' => $data_now->toString('YYYY-MM-dd'), 'decorators' => $this->setColSize(12)));
// Adicionando tag HTML usando description do elemento
$this->addElement('hidden', 'data_desc', array('ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-2 pull-right")))));
// Adicionando tag HTML usando description do elemento
$this->addElement('hidden', 'header3', array('description' => '<h3>FICHA DE ATENDIMENTO AO CLIENTE</h3>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
$this->addElement('text', 'nome', array('label' => 'Nome', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('text', 'cpf', array('label' => 'CPF', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
$this->addElement('select', 'estado_civil', array('label' => 'Estado Civil', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_estado_civil, 'validators' => array($required), 'decorators' => $this->setColSize(3)));
$this->addElement('text', 'email', array('label' => 'E-mail', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('text', 'data_nasc', array('label' => 'Data de Nascimento', 'required' => false, 'description' => '<span class="glyphicon glyphicon-calendar"></span>', 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3, true, true)));
// Adicionando tag HTML usando description do elemento
$this->addElement('hidden', 'hr_filiacao', array('description' => '<h3>FILIAÇÃO</h3>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
$this->addElement('text', 'filiacao_pai', array('label' => 'Pai', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('text', 'filiacao_mae', array('label' => 'Mãe', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
// Adicionando tag HTML usando description do elemento
$this->addElement('hidden', 'hr_end', array('description' => '<hr/>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
$this->addElement('text', 'cep', array('label' => 'CEP', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
$this->addElement('text', 'endereco', array('label' => 'Endereço', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(9)));
$this->addElement('text', 'bairro', array('label' => 'Bairro', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('select', 'estado', array('label' => 'Estado', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_empty, 'validators' => array($required), 'decorators' => $this->setColSize(6)));
$this->addElement('select', 'cidade', array('label' => 'Cidade', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_empty, 'validators' => array($required), 'decorators' => $this->setColSize(6)));
$this->addElement('text', 'fone_resid', array('label' => 'Fone Resid.', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(4)));
$this->addElement('text', 'fone_com', array('label' => 'Fone Com.', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(4)));
$this->addElement('text', 'fone_cel', array('label' => 'Celular', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(4)));
// Adicionando tag HTML usando description do elemento
$this->addElement('hidden', 'hr_contato', array('description' => '<hr/>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
$this->addElement('text', 'empresa_trabalha', array('label' => 'Empresa na qual trabalha', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize()));
$this->addElement('text', 'profissao', array('label' => 'Profissão', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('text', 'cargo', array('label' => 'Cargo', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('text', 'renda_familiar', array('label' => 'Renda Familiar', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
$this->addElement('select', 'renda', array('label' => 'Renda', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_renda, 'validators' => array($required), 'decorators' => $this->setColSize(6)));
$this->addElement('select', 'fgts', array('label' => 'FGTS', 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_sim_nao, 'decorators' => $this->setColSize(3)));
$this->addElement('select', 'fgts_tres_anos', array('label' => 'Mais de 3 anos', 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_sim_nao, 'decorators' => $this->setColSize(3)));
$this->addElement('text', 'saldo_fgts', array('label' => 'Saldo FGTS', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
$this->addElement('text', 'valor_entrada', array('label' => 'Valor de entrada', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
// Adicionando tag HTML usando description do elemento
$this->addElement('hidden', 'header3_atendimento', array('description' => '<h3>SOBRE O ATENDIEMENTO</h3>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
$this->addElement('select', 'meio_comunicacao', array('label' => 'Meio de Comunicação', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_meio_comunicacao, 'validators' => array($required), 'decorators' => $this->setColSize()));
$this->addElement('textarea', 'observacoes', array('label' => 'Observações', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'cols' => 80, 'rows' => 5, 'decorators' => $this->setColSize()));
$this->addElement('hidden', 'created_user_id', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
$this->addElement('hidden', 'last_user_id', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
$this->addElement('hidden', 'locked', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
$this->addElement('hidden', 'locked_by', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
$this->addElement('submit', 'Enviar', array('label' => 'Enviar', 'ignore' => 'true', 'class' => 'btn btn-success pull-right', 'decorators' => $this->setColSize(12, false)));
$this->setDecorators(array('FormElements', array(array('in' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row')), 'Form', array('HtmlTag', array('tag' => 'div', 'class' => 'panel panel-body panel-default'))));
$this->setAttrib('class', 'form');
$this->setAttrib('id', 'ficha-atendimento');
$this->setMethod('post');
}
示例6: init
public function init()
{
// Verifica se o campo select esta com o valor null
$required = new Zend_Validate_NotEmpty();
$required->setType($required->getType() | Zend_Validate_NotEmpty::INTEGER | Zend_Validate_NotEmpty::ZERO);
// Pega a lista de perfis no banco de dados na tabela #__perfis
$perfis = new Application_Model_Usuarios();
$lista_options = $perfis->getPerfis();
$options_perfil = array("-- Selecione --");
foreach ($lista_options as $option) {
$options_perfil[$option->id] = $option->role;
}
$this->addElement('text', 'nome', array('label' => 'Nome', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control'));
$this->addElement('text', 'email', array('label' => 'Email', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control'));
$this->addElement('select', 'id_perfil', array('label' => 'Perfil', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_perfil, 'validators' => array($required)));
$this->addElement('select', 'acesso', array('label' => 'Habilitado', 'required' => true, 'class' => 'form-control', 'multiOptions' => array('0' => 'não', '1' => 'sim')))->setDefault('acesso', '0');
$this->addElement('password', 'password', array('label' => 'Senha', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'autocomplete' => 'off', 'validators' => array(array('StringLength', false, array('min' => 4, 'max' => 10)))));
$this->addElement('password', 'confirm', array('label' => 'Confirma Senha', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'validators' => array(array('identical', false, array('token' => 'password')))));
$submit = $this->addElement('submit', 'Cadastrar', array('class' => 'btn btn-primary btn-md'));
$this->setElementDecorators(array('ViewHelper', 'Errors', 'Label', 'Description', array('HtmlTag', array('tag' => 'div', 'class' => 'form-group'))), array('Cadastrar'), false);
$this->setElementDecorators(array('ViewHelper', 'Errors', 'Description', array('HtmlTag', array('tag' => 'div', 'class' => 'form-group'))), array('Cadastrar'), true);
$this->setDecorators(array('FormElements', 'Form', array('HtmlTag', array('tag' => 'div', 'class' => 'panel panel-body panel-default'))));
$this->setAttrib('id', 'add_usuario');
$this->setAttrib('class', 'form');
$this->setMethod('post');
}
示例7: init
public function init()
{
$this->setMethod('post');
//The password element.
$passwordElement = new Zend_Form_Element_Password('password');
$passwordElement->setRequired(true);
$passwordElement->setLabel('New Password:');
$passwordElement->addValidator(new Zend_Validate_PasswordStrength());
$validator = new Zend_Validate_Identical();
$validator->setToken('confirm_password');
$validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME);
$passwordElement->addValidator($validator);
$this->addElement($passwordElement);
//The confirm password element.
$confirmPasswordElement = new Zend_Form_Element_Password('confirm_password');
$confirmPasswordElement->setRequired(true);
$confirmPasswordElement->setLabel('Confirm New Password:');
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Please confirm your password');
$confirmPasswordElement->addValidator($validator);
$this->addElement($confirmPasswordElement);
// Security question & answer
$this->addElement('select', 'security_question', array('label' => 'Security Question', 'required' => true, 'multiOptions' => array(0 => 'Please select'), 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))));
$this->addElement('text', 'security_answer', array('label' => 'Answer', 'required' => true, 'filters' => array('StringTrim'), 'attribs' => array('data-ctfilter' => 'yes')));
$this->addElement('hidden', 'instruction', array('required' => false));
$this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Save', 'class' => 'button'));
$this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div'))));
// Set up the decorator on the form and add in decorators which are removed
$this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'form_section one-col'))->addDecorator('Form');
$element = $this->getElement('submit');
$element->removeDecorator('label');
// Remove the label from the submit button
}
示例8: testIfCustomMessagesOnValidatorInstancesCanBeUsed
/**
* @group ZF-11267
* If we pass in a validator instance that has a preset custom message, this
* message should be used.
*/
function testIfCustomMessagesOnValidatorInstancesCanBeUsed()
{
// test with a Digits validator
require_once 'Zend/Validate/Digits.php';
require_once 'Zend/Validate/NotEmpty.php';
$data = array('field1' => 'invalid data');
$customMessage = 'Hey, that\'s not a Digit!!!';
$validator = new Zend_Validate_Digits();
$validator->setMessage($customMessage, 'notDigits');
$this->assertFalse($validator->isValid('foo'), 'standalone validator thinks \'foo\' is a valid digit');
$messages = $validator->getMessages();
$this->assertSame($messages['notDigits'], $customMessage, 'stanalone validator does not have custom message');
$validators = array('field1' => $validator);
$input = new Zend_Filter_Input(null, $validators, $data);
$this->assertFalse($input->isValid(), 'invalid input is valid');
$messages = $input->getMessages();
$this->assertSame($messages['field1']['notDigits'], $customMessage, 'The custom message is not used');
// test with a NotEmpty validator
$data = array('field1' => '');
$customMessage = 'You should really supply a value...';
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage($customMessage, 'isEmpty');
$this->assertFalse($validator->isValid(''), 'standalone validator thinks \'\' is not empty');
$messages = $validator->getMessages();
$this->assertSame($messages['isEmpty'], $customMessage, 'stanalone NotEmpty validator does not have custom message');
$validators = array('field1' => $validator);
$input = new Zend_Filter_Input(null, $validators, $data);
$this->assertFalse($input->isValid(), 'invalid input is valid');
$messages = $input->getMessages();
$this->assertSame($messages['field1']['isEmpty'], $customMessage, 'For the NotEmpty validator the custom message is not used');
}
示例9: setPassword
public function setPassword($password)
{
$valid = new Zend_Validate_NotEmpty();
if ($valid->isValid($password)) {
$this->_set('password', md5($password));
}
}
示例10: __construct
public function __construct($data)
{
$val = new Zend_Validate_NotEmpty();
$num = new Zend_Validate_Digits();
$date = new Zend_Validate_Date(array('format' => 'dd/MM/yyyy'));
if ($val->isValid($data['tendonhang']) == false) {
$this->messages[] = "Tên đơn hàng không được trống";
}
if ($date->isValid($data['ngaydathang']) == false) {
$this->messages[] = "Ngày đặt hàng không đúng";
}
if ($val->isValid($data['tiendathang']) == false) {
$this->messages[] = "Tiền đặt hàng Không được trống";
}
if ($num->isValid($data['tiendathang']) == false) {
$this->messages[] = "Tiền đặt hàng phải là số";
}
if ($num->isValid($data['sometvai']) == false) {
$this->messages[] = "Số mét vải phải là số";
}
if ($val->isValid($data['sometvai']) == false) {
$this->messages[] = "Số mét vải Không được trống";
}
if (array_key_exists('makhachhang', $data)) {
if ($num->isValid($data['makhachhang']) == false) {
$this->messages[] = "Mã khách hàng phải là số";
}
if ($val->isValid($data['makhachhang']) == false) {
$this->messages[] = "Mã khách hàng không được trống";
}
}
}
示例11: __construct
public function __construct($options = null)
{
$baseDir = $options['baseDir'];
$pageID = $options['pageID'];
parent::__construct($options);
/****************************************/
// PARAMETERS
/****************************************/
// select box category (Parameter #1)
$blockCategory = new Zend_Form_Element_Select('Param1');
$blockCategory->setLabel('Catégorie d\'évènement de ce bloc')->setAttrib('class', 'largeSelect');
$categories = new Categories();
$select = $categories->select()->setIntegrityCheck(false)->from('Categories')->join('CategoriesIndex', 'C_ID = CI_CategoryID')->where('C_ModuleID = ?', 7)->where('CI_LanguageID = ?', Zend_Registry::get("languageID"))->order('CI_Title');
$categoriesArray = $categories->fetchAll($select);
foreach ($categoriesArray as $category) {
$blockCategory->addMultiOption($category['C_ID'], $category['CI_Title']);
}
// number of news to show in front-end (Parameter #2)
$at_least_one = new Zend_Validate_GreaterThan('0');
$at_least_one->setMessage('Vous devez afficher au moins un événement.');
$not_null = new Zend_Validate_NotEmpty();
$not_null->setMessage($this->getView()->getCibleText('validation_message_empty_field'));
$blockNewsMax = new Zend_Form_Element_Text('Param2');
$blockNewsMax->setLabel('Nombre d\'évènement à afficher')->setRequired(true)->setValue('1')->addValidator($not_null, true)->addValidator($at_least_one, true)->setAttrib('class', 'smallTextInput');
// show the breif text in front-end (Parameter #3)
$blockShowBrief = new Zend_Form_Element_Checkbox('Param3');
$blockShowBrief->setLabel('Afficher le texte bref');
$blockShowBrief->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
$this->addElements(array($blockCategory, $blockNewsMax, $blockShowBrief));
$this->removeDisplayGroup('parameters');
$this->addDisplayGroup(array('Param999', 'Param1', 'Param2', 'Param3'), 'parameters');
$parameters = $this->getDisplayGroup('parameters');
//$parameters->setLegend($this->_view->getCibleText('form_parameters_fieldset'));
}
示例12: init
public function init()
{
/* Form Elements & Other Definitions Here ... */
// TODO setMethod
$element = new Zend_Form_Element_Text('prenom');
$element->setLabel('Prénom')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le prénom est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$validator = new Zend_Validate_StringLength();
$validator->setMax(40);
$element->addValidator($validator);
$filter = new Zend_Filter_StringTrim();
$element->addFilter($filter);
$this->addElement($element);
$element = new Zend_Form_Element_Text('nom');
$element->setLabel('Nom')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le nom est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$this->addElement($element);
$element = new Zend_Form_Element_Text('email');
$element->setLabel('Email');
$this->addElement($element);
$element = new Zend_Form_Element_Text('telephone');
$element->setLabel('Téléphone');
$this->addElement($element);
}
示例13: indexAction
public function indexAction()
{
$emailValidator = new Zend_Validate_EmailAddress();
$nameValidator = new Zend_Validate_NotEmpty(array(Zend_Validate_NotEmpty::STRING, Zend_Validate_NotEmpty::SPACE));
$password1_Validator = new Zend_Validate();
$password1_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
$password2_Validator = new Zend_Validate();
$password2_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
$captcha = new Zend_Captcha_Image();
$captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300);
$request = $this->getRequest();
$post = $request->getPost();
// $passwordIdentical = new Zend_Validate_Identical(array('token' => $post['password1']));
$messages = array();
$error = array();
$noValiError = true;
if ($this->getRequest()->isPost()) {
if (!$emailValidator->isValid($post['user-email'])) {
$error['user-emailVali'] = '請輸入正確的Email帳號';
$noValiError = false;
}
if (!$nameValidator->isValid($post['name'])) {
$error['nameVali'] = '姓名必填';
$noValiError = false;
}
if (!$password1_Validator->isValid($post['password1'])) {
$error['password1_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
$noValiError = false;
}
if (!$password2_Validator->isValid($post['password2'])) {
$error['password2_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
$noValiError = false;
}
if (isset($post['password1']) && isset($post['password2']) && !($post['password1'] == $post['password2'])) {
$error['passwordIdentical'] = '2.密碼輸入不同';
$noValiError = false;
}
if (!($post['agree'] == 1)) {
$error['agreeVali'] = '需同意服務條款及隱私權政策,才可以註冊';
$noValiError = false;
}
if (!$captcha->isValid($post['captchaword'])) {
$error['captchawordVali'] = '認證碼輸入錯誤';
$noValiError = false;
}
if ($noValiError) {
// register process
$this->_signup($post);
$this->view->messages = $post;
$this->redirect('index/index');
} else {
$this->_genCaptcha($captcha);
$this->view->error = $error;
$this->view->messages = $post;
}
} else {
$this->_genCaptcha($captcha);
}
}
示例14: check_empty
public function check_empty($value)
{
$validator = new Zend_Validate_NotEmpty();
if (!$validator->isValid($value) == true) {
$error = "Enter you data";
return $error;
}
}
示例15: __construct
public function __construct($data)
{
$val = new Zend_Validate_NotEmpty();
$num = new Zend_Validate_Digits();
if ($val->isValid($data['tenloaisoi']) == false) {
$this->messages[] = "Tên loại vải không được trống";
}
}