本文整理汇总了PHP中Zend\InputFilter\Input::setRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::setRequired方法的具体用法?PHP Input::setRequired怎么用?PHP Input::setRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\InputFilter\Input
的用法示例。
在下文中一共展示了Input::setRequired方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Input
function __construct()
{
parent::__construct('console_address');
$element_id = new Element\Hidden('id');
$element_id->setValue('');
$this->add($element_id);
$this->add(array('name' => 'username', 'type' => 'Text'));
$this->add(array('name' => 'domain', 'type' => 'Text'));
$this->add(array('name' => 'nickname', 'type' => 'Text'));
$element_sex = new Element\Select('sex');
$element_sex->setValueOptions(array(self::ADDRESS_SEX_BOY => '男性', self::ADDRESS_SEX_GIRL => '女性'));
$this->add($element_sex);
$this->add(array('name' => 'submit', 'type' => 'Submit'));
/**
* Setting up inputFilter
*/
$input_id = new Input('id');
$input_id->setRequired(false)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)))->attach(new \Zend\Validator\Digits());
$input_username = new Input('username');
$input_username->setRequired(true)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 18)))->attach(new \Zend\Validator\Digits());
$input_filter = new InputFilter();
$input_filter->add($input_id);
$input_filter->add($input_username);
$this->setInputFilter($input_filter);
}
示例2: __construct
public function __construct()
{
$email = new Input('email');
$email->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$email->getValidatorChain()->attach(new NotEmpty());
$this->add($email);
}
示例3: __construct
public function __construct(LabServiceInterface $labService, AssetServiceInterface $assetsService)
{
$id = new Input('id');
$id->setRequired(false)->getValidatorChain()->attach(new Validator\Digits());
$itemCategoryId = new Input('itemcategory_id');
$itemCategoryId->setRequired(true)->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Callback(['callback' => function ($value) use($assetsService) {
try {
$itemCategory = $assetsService->getItemCategoryById($value);
return isset($itemCategory['id']) && $itemCategory['id'] == $value;
} catch (Exception $ex) {
return false;
}
}, 'message' => 'Ο τύπος δεν βρέθηκε']));
$labId = new Input('lab_id');
$labId->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$labId->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Callback(['callback' => function ($value) use($labService) {
try {
$lab = $labService->getLabById($value);
return isset($lab['id']) && $lab['id'] == $value;
} catch (Exception $ex) {
return false;
}
}, 'message' => 'Το εργαστήριο δεν βρέθηκε']));
$qty = new Input('qty');
$qty->setRequired(true)->getFilterChain()->attach(new Filter\Digits())->attach(new Filter\ToInt());
$qty->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\GreaterThan(['min' => 0]));
$acquisitionYear = new Input('acquisition_year');
$acquisitionYear->setRequired(false)->getFilterChain()->attach(new Filter\Digits());
$acquisitionYear->getValidatorChain()->attach(new Validator\Date(['format' => 'Y']))->attach(new Validator\LessThan(['max' => date('Y'), 'inclusive' => true]));
$comments = new Input('comments');
$comments->setRequired(false)->getFilterChain()->attach(new Filter\StripTags())->attach(new Filter\StringTrim());
$this->inputFilter = new InputFilter();
$this->inputFilter->add($id)->add($labId)->add($itemCategoryId)->add($qty)->add($acquisitionYear)->add($comments);
}
示例4: getInputFilter
/**
* @return InputFilterInterface
*/
public function getInputFilter()
{
if (!$this->inputFilter) {
$searchParam = new Input('search_param');
$searchParam->setAllowEmpty(false);
$searchParam->setRequired(true);
$radius = new Input('radius');
$radius->setAllowEmpty(true);
$radius->setRequired(false);
$city = new Input('city');
$city->setAllowEmpty(true);
$city->setRequired(false);
$state = new Input('state');
$state->setAllowEmpty(true);
$state->setRequired(false);
$postalCode = new Input('postal_code');
$postalCode->setAllowEmpty(true);
$postalCode->setRequired(false);
// $contactEmail = new Input('contact_email');
// $contactEmail ->setRequired(false);
// $contactEmail ->setAllowEmpty(true)
// ->getValidatorChain()
// ->addValidator(new \Zend\Validator\EmailAddress());
$inputFilter = new InputFilter();
$inputFilter->add($searchParam)->add($radius)->add($city)->add($state)->add($postalCode);
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例5: __construct
public function __construct()
{
$translator = new \Zend\I18n\Translator\Translator();
$translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
$translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
\Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
$nombre = new Input('nome');
$nombre->setRequired(true);
$nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
$this->add($nombre);
$password = new Input('password');
$password->setRequired(true);
$password->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
$this->add($password);
$confirmarPassword = new Input('confirmarPassword');
$confirmarPassword->setRequired(true);
$confirmarPassword->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum))->addValidator(new Identical(array('token' => 'password', 'messages' => array('notSame' => 'I dati sono errati, riprova.'))));
$this->add($confirmarPassword);
$imagen = new FileInput('immagine');
$imagen->setRequired(false);
$imagen->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/utenti/utenti_', 'use_upload_extension' => true, 'randomize' => true)));
$imagen->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
/*
$imagen->getValidatorChain()->attach(new MimeType(array(
'mimeType' => 'image/png,image/x-png,image/gif,image/jpeg,image/pjpeg', 'enableHeaderCheck' => true
)));
*/
$this->add($imagen);
}
示例6: 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);
}
示例7: __construct
public function __construct(array $categoria = array())
{
$this->categoria = $categoria;
//Titulo
$titulo = new Input('titulo');
$titulo->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$titulo->getValidatorChain()->attach(new NotEmpty());
$this->add($titulo);
//Descricao
$descricao = new Input('descricao');
$descricao->setRequired(false)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$this->add($descricao);
//Texto
$texto = new Input('texto');
$texto->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$texto->getValidatorChain()->attach(new NotEmpty());
$this->add($texto);
//ativo
$ativo = new Input('ativo');
$ativo->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$this->add($ativo);
$inArray = new InArray();
$inArray->setOptions(array('haystack' => $this->haystack($this->categoria)));
$categoria = new Input('category');
$categoria->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$categoria->getValidatorChain()->attach($inArray);
$this->add($categoria);
}
示例8: __construct
public function __construct(EntityManager $objectManager)
{
// Nom
$nom = new Input('nom');
$nom->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$nom->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 50)));
$this->add($nom);
// Image
$image = new Input('image');
$image->setRequired(false);
// TODO
$this->add($image);
// Date début
$dateDebut = new Input('dateDebut');
$dateDebut->setRequired(true);
//->getValidatorChain()
//->attach(new DateTime(array('format' => 'd/m/Y')));
// TODO
//$this->add($dateDebut);
// Date fin
$dateFin = new Input('dateFin');
$dateFin->setRequired(true);
//->getValidatorChain()
//->attach(new DateTime(array('format' => 'd/m/Y')));
// TODO
//$this->add($dateFin);
// TODO joueurs
}
示例9: getInputFilter
public function getInputFilter()
{
if (is_null($this->filter)) {
$trackingIdValidator = new StringLength(36);
$regexValidator = new Regex('/^[a-zA-Z0-9_-]+$/');
$trackingIdInput = new Input('trackingId');
$trackingIdInput->allowEmpty();
$trackingIdInput->setRequired(false);
$trackingIdInput->getValidatorChain()->attach($trackingIdValidator)->attach($regexValidator);
$inArrayValidator = new InArray();
$inArrayValidator->setHaystack(array_keys($this->locations));
$originInput = new Input('origin');
$originInput->getValidatorChain()->attach($inArrayValidator);
$notSameValidator = new Callback(array('callback' => function ($value, $context = null) {
if ($context) {
return $value !== $context['origin'];
}
return true;
}, 'messages' => array(Callback::INVALID_VALUE => 'Origin and Destination are the same')));
$destinationInput = new Input('final_destination');
$destinationInput->getValidatorChain()->attach($inArrayValidator)->attach($notSameValidator);
$filter = new InputFilter();
$filter->add($trackingIdInput)->add($originInput)->add($destinationInput);
$this->filter = $filter;
}
return $this->filter;
}
示例10: __construct
public function __construct()
{
$this->inputFilter = new InputFilter();
$id = new Input('id_equalTo');
$id->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$id->setRequired(false);
$mailTo = new Input('mailTo_like');
$mailTo->getFilterChain()->attachByName('StringTrim');
$mailTo->getValidatorChain()->attachByName('StringLength', ['min' => 0, 'max' => 50]);
$mailTo->setRequired(false);
$layoutId = new Input('layoutId_equalTo');
$layoutId->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0, 'max' => 1]);
$layoutId->setRequired(false);
$templateId = new Input('templateId_equalTo');
$templateId->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0, 'max' => 7]);
$templateId->setRequired(false);
$limit = new Input('limit');
$limit->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$limit->setRequired(false);
$page = new Input('page');
$page->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$page->setRequired(false);
$createdDtLessThen = new Input('createdDt_lessThan');
$createdDtLessThen->setRequired(false);
$createdDtGreaterThan = new Input('createdDt_greaterThan');
$createdDtGreaterThan->setRequired(false);
$this->inputFilter->add($id);
$this->inputFilter->add($mailTo);
$this->inputFilter->add($layoutId);
$this->inputFilter->add($templateId);
$this->inputFilter->add($limit);
$this->inputFilter->add($page);
$this->inputFilter->add($createdDtLessThen);
$this->inputFilter->add($createdDtGreaterThan);
}
示例11: __construct
public function __construct(AuthenticationService $authService)
{
parent::__construct('login');
$this->filter = new InputFilter();
$email = new Element\Email('email');
$email->setAttribute('required', true);
$email->setAttribute('placeholder', 'Email Address');
$this->add($email);
$emailFilter = new Input('email');
$emailFilter->setRequired(true);
$this->filter->add($emailFilter);
$password = new Element\Password('password');
$password->setAttribute('required', true);
$password->setAttribute('placeholder', 'Password');
$this->add($password);
$passwordFilter = new Input('password');
$passwordFilter->setRequired(true);
$passwordFilter->getValidatorChain()->attach(new AuthValidator\Authentication(array('message' => 'Invalid email address or password', 'service' => $authService, 'adapter' => $authService->getAdapter(), 'identity' => 'email', 'credential' => 'password')));
$this->filter->add($passwordFilter);
$buttons = new Form('buttons');
$buttons->setOption('twb-layout', 'inline');
$buttons->setAttribute('class', 'form-group');
$submit = new Element\Submit('submit');
$submit->setAttribute('class', 'btn-primary pull-right');
$submit->setOption('glyphicon', 'log-in');
$submit->setLabel('Log In');
$buttons->add($submit);
$forgot = new Element\Submit('forgot');
$forgot->setAttribute('formnovalidate', true);
$forgot->setAttribute('class', 'btn-warning pull-right');
$forgot->setOption('glyphicon', 'question-sign');
$forgot->setLabel('Forgot Password');
$buttons->add($forgot);
$this->add($buttons);
}
示例12: __construct
public function __construct()
{
$input = new Input('userId');
$input->setRequired(true);
$input->getValidatorChain()->attach(new \Zend\I18n\Validator\IsInt())->attach(new Validator\NotEmpty());
$this->add($input);
$input = new Input('currencyFrom');
$input->setRequired(true);
$input->getValidatorChain()->attach(new Validator\NotEmpty());
$this->add($input);
$input = new Input('currencyTo');
$input->setRequired(true);
$input->getValidatorChain()->attach(new Validator\NotEmpty());
$this->add($input);
$input = new Input('amountSell');
$input->setRequired(true);
$input->getValidatorChain()->attach(new \Zend\I18n\Validator\IsFloat())->attach(new Validator\NotEmpty());
$this->add($input);
$input = new Input('amountBuy');
$input->setRequired(true);
$input->getValidatorChain()->attach(new \Zend\I18n\Validator\IsFloat())->attach(new Validator\NotEmpty());
$this->add($input);
$input = new Input('rate');
$input->setRequired(true);
$input->getValidatorChain()->attach(new \Zend\I18n\Validator\IsFloat())->attach(new Validator\NotEmpty());
$this->add($input);
$input = new Input('timePlaced');
$input->setRequired(true);
$input->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Date(['format' => 'd-M-y H:i:s']));
$this->add($input);
$input = new Input('originatingCountry');
$input->setRequired(true);
$input->getValidatorChain()->attach(new Validator\NotEmpty());
$this->add($input);
}
示例13: __construct
public function __construct($uploadTmpPath, LabServiceInterface $labService, $attachmentSize)
{
$id = new Input('id');
$id->setRequired(false)->getValidatorChain()->attach(new Validator\Digits());
$name = new Input('name');
$name->setRequired(true)->getFilterChain()->attach(new Filter\StringTrim());
$name->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\StringLength(['min' => 3]));
$labTypeId = new Input('labtype_id');
$labTypeId->setRequired(true);
$labTypeId->getValidatorChain()->attach(new Validator\NotEmpty());
$isNew = new Input('is_new');
$isNew->setRequired(false)->getFilterChain()->attach(new Filter\ToInt());
$responsibleId = new Input('responsible_id');
$responsibleId->setRequired(false)->getValidatorChain()->attach(new Validator\Digits());
$area = new Input('area');
$area->setRequired(true)->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Digits());
$lessons = new Input('lessons');
$lessons->setRequired(false);
$lessons->getValidatorChain()->attach(new Validator\NotEmpty());
$attachment = new FileInput('attachment');
$attachment->setRequired(false)->getFilterChain()->attach(new Filter\File\RenameUpload(['target' => $uploadTmpPath, 'randomize' => true]));
$attachment->getValidatorChain()->attach(new Validator\File\UploadFile())->attach(new Validator\File\MimeType(['application/zip', 'application/x-rar-compressed', 'application/octet-stream', 'application/pdf', 'image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff', 'image/svg+xml', 'image/svg+xml', 'image/vnd.adobe.photoshop']))->attach(new Validator\File\Size(['max' => $attachmentSize]));
$use_ext_program = new Input('use_ext_program');
$use_ext_program->setRequired(false);
$use_in_program = new Input('use_in_program');
$use_in_program->setRequired(false);
$has_network = new Input('has_network');
$has_network->setRequired(false);
$has_network->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\InArray(['haystack' => $labService->getHasNetworkValues()]));
$has_server = new Input('has_server');
$has_server->setRequired(false);
$has_server->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\InArray(['haystack' => $labService->getHasServerValues()]));
$this->inputFilter = new InputFilter();
$this->inputFilter->add($id)->add($name)->add($labTypeId)->add($isNew)->add($responsibleId)->add($area)->add($lessons)->add($attachment)->add($use_in_program)->add($use_ext_program)->add($has_server)->add($has_network);
}
示例14: __construct
/**
* CriarControllerFilter constructor.
*/
public function __construct()
{
# filter for strForm
$strForm = new Input('strForm');
$strForm->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$strForm->getValidatorChain()->attach(new NotEmpty());
$this->add($strForm);
# filter for strController
$strController = new Input('strController');
$strController->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$strController->getValidatorChain()->attach(new NotEmpty());
$this->add($strController);
# filter for strRoute
$strRoute = new Input('strRoute');
$strRoute->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$strRoute->getValidatorChain()->attach(new NotEmpty());
$this->add($strRoute);
# filter for strService
$strService = new Input('strService');
$strService->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$strService->getValidatorChain()->attach(new NotEmpty());
$this->add($strService);
# filter for strEntity
$strEntity = new Input('strEntity');
$strEntity->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$strEntity->getValidatorChain()->attach(new NotEmpty());
$this->add($strEntity);
}
示例15: __construct
public function __construct(LabServiceInterface $labService, AssetServiceInterface $assetsService)
{
$labId = new Input('lab_id');
$labId->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$labId->getValidatorChain()->attach(new Validator\NotEmpty());
$itemCategoryId = new Input('itemcategory_id');
$itemCategoryId->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$itemCategoryId->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Callback(['callback' => function ($value) use($assetsService) {
try {
$type = $assetsService->getItemCategoryById($value);
return $type && $type['id'] == $value;
} catch (Exception $ex) {
return false;
}
}, 'message' => 'Ο τύπος εξοπλισμού δεν είναι έγκυρος']));
$qty = new Input('qty');
$qty->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$qty->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\GreaterThan(['min' => 0]));
$qtyacquired = new Input('qtyacquired');
$qtyacquired->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$qtyacquired->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\GreaterThan(['min' => 0, 'inclusive' => true]));
$reasons = new Input('reasons');
$reasons->setRequired(true)->getFilterChain()->attach(new Filter\StripTags())->attach(new Filter\StringTrim());
$reasons->getValidatorChain()->attach(new Validator\NotEmpty());
$this->add($labId)->add($itemCategoryId)->add($qty)->add($qtyacquired)->add($reasons);
}