本文整理匯總了PHP中Zend\InputFilter\InputFilter::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputFilter::add方法的具體用法?PHP InputFilter::add怎麽用?PHP InputFilter::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\InputFilter\InputFilter
的用法示例。
在下文中一共展示了InputFilter::add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInputFilter
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
/* @campo id
* @filters Int
*/
$inputFilter->add(array('name' => 'id', 'required' => false, 'filters' => array(array('name' => 'Int'))));
/* @campo fk_categoria
* @filters StripTags
* @filters StringTrim
* @validators NotEmpty
* @validators Digits
*/
$inputFilter->add(array('name' => 'fk_categoria', 'required' => true, 'allow_empty' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Campo obrigatório!'))), array('name' => 'Digits', 'break_chain_on_failure' => true, 'options' => array('messages' => array('notDigits' => 'Campo só aceita numeros'))))));
/* @campo nome
* @filters StripTags
* @filters StringTrim
* @validators NotEmpty
* @validators StringLength
* @validators Validador\TesteUnicidade
*/
$inputFilter->add(array('name' => 'nome', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Campo obrigatório!'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('encoding' => 'UTF-8', 'min' => 3, 'max' => 40, 'messages' => array('stringLengthTooShort' => 'O valor digitado deve possuir no minimo %min% caractere', 'stringLengthTooLong' => 'O valor digitado deve possuir no maximo %max% caractere'))), array('name' => 'Validador\\TesteUnicidade', 'options' => array('adapter' => $this->dbAdapter, 'tabela' => 'despesas_subcategorias', 'campo' => 'nome', 'camposExtra' => array('fk_categoria'), 'negar' => array('id')), 'break_chain_on_failure' => true))));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例2: getInputFilter
public function getInputFilter()
{
$inputFilter = new InputFilter();
$inputFilter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => sprintf('%sを入力してください。', 'メールアドレス')))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('encoding' => 'UTF-8', 'min' => 0, 'max' => 100, 'message' => array(\Zend\Validator\StringLength::TOO_LONG => sprintf('%sは%s文字以內で入力してください。', 'メールアドレス', '100')))), array('name' => 'EmailAddress', 'options' => array('message' => array(\Zend\Validator\EmailAddress::INVALID_FORMAT => sprintf('%sは有効な形式で入力してください。', 'メールアドレス')))))));
$inputFilter->add(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => sprintf('%sを入力してください。', 'パスワード'))), 'name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('encoding' => 'UTF-8', 'min' => 6, 'messages' => array(\Zend\Validator\StringLength::TOO_SHORT => sprintf('%sを最低%s文字で入力してください。', 'パスワード', '6')))))));
return $inputFilter;
}
示例3: getInputFilter
public function getInputFilter()
{
$maxvalidator = new Validator\StringLength();
$maxvalidator->setMax(50);
$minvalidator = new Validator\StringLength();
$minvalidator->setMin(4);
$email = new Input('email');
$email->getValidatorChain()->attach(new Validator\EmailAddress());
$email->getValidatorChain()->attach($maxvalidator);
$email->getValidatorChain()->attach($minvalidator);
$password = new Input('password');
$password->getValidatorChain()->attach($maxvalidator);
$password->getValidatorChain()->attach(new Validator\StringLength(array('min' => 6)));
$first_name = new Input('first_name');
$first_name->getValidatorChain()->attach($maxvalidator);
$first_name->getValidatorChain()->attach($minvalidator);
$user_name = new Input('username');
$user_name->getValidatorChain()->attach($maxvalidator);
$user_name->getValidatorChain()->attach($minvalidator);
$inputFilter = new InputFilter();
$inputFilter->add($email);
$inputFilter->add($password);
$inputFilter->add($first_name);
$inputFilter->add($user_name);
return $inputFilter;
}
示例4: validadores
public function validadores()
{
$inputFilter = new InputFilter();
$inputFilter->add(array('name' => 'va_email', 'required' => true, 'validators' => array(array('name' => 'EmailAddress'))));
$inputFilter->add(array('name' => 'va_contrasena', 'required' => true));
return $inputFilter;
}
示例5: getLeaveFilter
public function getLeaveFilter()
{
$filter = new InputFilter();
$filter->add(array('name' => 'leaveType', 'required' => true));
$filter->add(array('name' => 'description', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'max' => 500, 'min' => 1, 'encoding' => 'UTF-8'))));
return $filter;
}
示例6: getInputFilter
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
/*
$inputFilter->add($factory->createInput(array(
'name' => 'name',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
)));
*/
$inputFilter->add($factory->createInput(array('name' => 'min_start_range', 'required' => true)));
$inputFilter->add($factory->createInput(array('name' => 'max_start_range', 'required' => true)));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例7: initFilters
protected function initFilters()
{
$filter = new InputFilter();
$filter->add(['name' => 'lidnr', 'required' => true, 'validators' => [['name' => 'not_empty'], ['name' => 'digits']]]);
$filter->add(['name' => 'email', 'required' => true, 'validators' => [['name' => 'not_empty'], ['name' => 'email_address']]]);
$this->setInputFilter($filter);
}
示例8: Input
function __construct()
{
parent::__construct('merchant_setting');
$this->add(array('name' => 'alipay_account', 'type' => 'Text'));
$this->add(array('name' => 'bank_type', 'type' => 'Text'));
$this->add(array('name' => 'bank_account_name', 'type' => 'Text'));
$this->add(array('name' => 'bank_account_card', 'type' => 'Text'));
$this->add(array('name' => 'submit', 'type' => 'Submit'));
/**
* Setting up inputFilter
*/
$input_AlipayAccount = new Input('alipay_account');
$input_AlipayAccount->setRequired(false);
$input_AlipayAccount->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_AlipayAccount->getValidatorChain()->attach(new \Zend\Validator\EmailAddress());
$input_BankType = new Input('bank_type');
$input_BankType->setRequired(false);
$input_BankType->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_BankAccountName = new Input('bank_account_name');
$input_BankAccountName->setRequired(false);
$input_BankAccountName->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_BankAccountCard = new Input('bank_account_card');
$input_BankAccountCard->setRequired(false);
$input_BankAccountCard->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_BankAccountCard->getValidatorChain()->attach(new \Zend\Validator\Digits());
$input_filter = new InputFilter();
$input_filter->add($input_AlipayAccount);
$input_filter->add($input_BankType);
$input_filter->add($input_BankAccountName);
$input_filter->add($input_BankAccountCard);
$this->setInputFilter($input_filter);
}
示例9: loginAction
public function loginAction()
{
$form = new LoginForm('', false, $this->getServiceLocator());
$request = $this->getRequest();
if ($request->isPost()) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array('name' => 'username', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty')))));
$inputFilter->add($factory->createInput(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty')))));
$form->setInputFilter($inputFilter);
$form->setData($request->getPost());
if ($form->isValid()) {
//check authentication...
$this->getAuthService()->getAdapter()->setIdentity('' . $request->getPost('username'))->setCredential('' . $request->getPost('password'));
$result = $this->getAuthService()->authenticate();
foreach ($result->getMessages() as $message) {
//save message temporary into flashmessenger
$this->flashmessenger()->addMessage($message);
}
if ($result->isValid()) {
$this->getAuthService()->getStorage()->write($this->getAuthService()->getAdapter()->getResultRowObject(null));
return $this->redirect()->toRoute('bhome');
}
}
}
return array('form' => $form);
}
示例10: getInputFilter
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array('name' => 'UID', 'required' => true, 'filters' => array(array('name' => 'Int')))));
$inputFilter->add($factory->createInput(array('name' => 'NOMBRE', 'required' => true)));
$inputFilter->add($factory->createInput(array('name' => 'APELLIDO', 'required' => true)));
$inputFilter->add($factory->createInput(array('name' => 'USER_NAME', 'required' => true)));
$inputFilter->add($factory->createInput(array('name' => 'EMAIL', 'required' => true)));
/*$inputFilter->add($factory->createInput(array(
'name' => 'title',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
)));*/
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例11: createInputFilter
/**
* Définition des filtres et des validateurs
* @return \Zend\InputFilter\InputFilter
*/
private function createInputFilter()
{
$inputFilter = new InputFilter();
$inputFilter->add(array('name' => 'libelle', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 45)))));
$inputFilter->add(array('name' => 'nblits', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'Int'), array('name' => 'GreaterThan', 'options' => array('min' => 0)))));
return $inputFilter;
}
示例12: getInputFilter
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(['name' => 'item_id', 'required' => true, 'filters' => array(array("name" => "Int")), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'It was not possible to find the package to change the participant for.'), 'callback' => function ($value, $context = array()) {
# check if order with the id of $value exists
if (!is_numeric($value)) {
return false;
}
$em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
$item = $em->getRepository("ErsBase\\Entity\\Item")->findOneBy(array('id' => $value));
if ($item) {
return true;
}
return false;
})))]));
$inputFilter->add($factory->createInput(['name' => 'user_id', 'required' => true, 'filters' => array(array("name" => "Int")), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'It was not possible to find the user that should be set as participant.'), 'callback' => function ($value, $context = array()) {
# check if user with the id of $value exists
if (!is_numeric($value)) {
return false;
}
$em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
$user = $em->getRepository("ErsBase\\Entity\\User")->findOneBy(array('id' => $value));
if ($user) {
return true;
}
return false;
})))]));
$inputFilter->add($factory->createInput(['name' => 'comment', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty'))]));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例13: validadores
public function validadores()
{
$inputFilter = new InputFilter();
$inputFilter->add(array('name' => 'va_contrasena', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 6, 'max' => 128)))));
$inputFilter->add(array('name' => 'verificar_contrasena', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('min' => 6)), array('name' => 'identical', 'options' => array('token' => 'va_contrasena')))));
return $inputFilter;
}
示例14: initFilters
protected function initFilters()
{
$filter = new InputFilter();
$filter->add(['name' => 'startDate', 'required' => true, 'validators' => [['name' => 'date']], 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']]]);
$filter->add(['name' => 'expirationDate', 'required' => true, 'validators' => [['name' => 'date']], 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']]]);
$this->setInputFilter($filter);
}
示例15: addInputFilter
public function addInputFilter()
{
$inputFilter = new InputFilter();
$inputFilter->add(array('name' => 'name', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 3, 'max' => 20)))));
$inputFilter->add(array('name' => 'desc', 'required' => false, 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 500)))));
$this->setInputFilter($inputFilter);
}