本文整理汇总了PHP中Zend\InputFilter\Input::setAllowEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::setAllowEmpty方法的具体用法?PHP Input::setAllowEmpty怎么用?PHP Input::setAllowEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\InputFilter\Input
的用法示例。
在下文中一共展示了Input::setAllowEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instantiateInput
/**
* Instantiate an Input object for the supplied field call setAllowEmpty()
* depending upon whether the field is required.
*
* @param Field $field
* @return Input
*/
protected function instantiateInput(Field $field)
{
$input = new Input($field->getControlName());
if ($field->isRequired() && !$field->isType('boolean')) {
$input->setAllowEmpty(false);
} else {
$input->setAllowEmpty(true);
}
return $input;
}
示例2: 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;
}
示例3: buildFilter
public function buildFilter()
{
//category char 16 not null,
$category = new Input('category');
$category->setAllowEmpty(TRUE);
$category->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags')->attachByName('StringToLower');
$category->getValidatorChain()->attachByName('inArray', array('haystack' => $this->categories));
//title varchar 128 not null
$title = new Input('title');
$title->setAllowEmpty(TRUE);
$title->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags');
$titleRegex = new Regex(array('pattern' => '/^[a-zA-Z0-9 ]*$/'));
$titleRegex->setMessage('Title should contain only numbers, letters or spaces.');
$title->getValidatorChain()->attach($titleRegex)->attachByName('StringLength', array('min' => 1, 'max' => 128));
//date_created timestamp not null default current_timestamp
$dateCreated = new Input('dateCreated');
$dateCreated->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags');
$dateCreated->getValidatorChain()->attachByName('StringLength', array('min' => 10, 'max' => 10));
// date_expires timestamp not null default null
// descripton varchar 4096 default null
// photo_filename varchar 1024 default null
// contact_name varchar 255 default null
// contact_email varchar 255 default null
// contact_phone varchar 32 default null
// city varchar 128 default null
// country char 2 not null
// price decimal 12,2 not null
// delete_code char 16 character set utf8 collate utf8_bin default null
$this->add($category)->add($title)->add($dateCreated);
}
示例4: buildFilter
public function buildFilter()
{
/******************************************************************
* Isto é um exemplo de como realizar a configurações do filtro,
* O importante é registrar o campos do formulário pedidos no exercícios
**********************************************************************/
// filter & validate by fields
$category = new Input('category');
$category->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags')->attachByName('StringToLower');
$category->getValidatorChain()->attachByName('InArray', array('haystack' => $this->getCategories()));
$title = new Input('title');
$title->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags');
$titleRegex = new Regex(array('pattern' => '/^[a-zA-Z0-9 ]*$/'));
$titleRegex->setMessage('Title should only contain numbers, letters or spaces!');
$title->getValidatorChain()->attach($titleRegex)->attachByName('StringLength', array('min' => 1, 'max' => 128));
$photo = new Input('photo_filename');
$photo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$photo->getValidatorChain()->attachByName('Regex', array('pattern' => '!^(http://)?[a-z0-9./_-]+(jp(e)?g|png)$!i'));
$photo->setErrorMessage('Photo must be a URL or a valid filename ending with jpg or png');
$price = new Input('price');
$price->setAllowEmpty(TRUE);
$price->getValidatorChain()->addByName('GreaterThan', array('min' => 0.0));
$price->getFilterChain()->attach(new Float());
// custom filter
$expires = new Input('expires');
$expires->setAllowEmpty(TRUE);
$expires->getValidatorChain()->attachByName('InArray', array('haystack' => array_keys($this->getExpireDays())));
$expires->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$city = new Input('cityCode');
$city->setAllowEmpty(TRUE);
$city->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$name = new Input('contact_name');
$name->setAllowEmpty(TRUE);
$name->getValidatorChain()->attachByName('Regex', array('pattern' => '/^[a-z0-9., -]{1,255}$/i'));
$name->setErrorMessage('Name should only contain letters, numbers, and some punctuation.');
$name->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$phone = new Input('contact_phone');
$phone->setAllowEmpty(TRUE);
$phone->getValidatorChain()->attachByName('Regex', array('pattern' => '/^\\+?\\d{1,4}(-\\d{3,4})+$/'));
$phone->setErrorMessage('Phone number must be in this format: +nnnn-nnn-nnn-nnnn');
$phone->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$email = new Input('contact_email');
$email->setAllowEmpty(TRUE);
$email->getValidatorChain()->attachByName('EmailAddress');
$email->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$description = new Input('description');
$description->setAllowEmpty(TRUE);
$description->getValidatorChain()->attachByName('StringLength', array('min' => 1, 'max' => 4096));
$description->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$delCode = new Input('delete_code');
$delCode->setRequired(TRUE);
$delCode->getValidatorChain()->addByName('Digits');
$this->add($category)->add($title)->add($photo)->add($price)->add($expires)->add($city)->add($name)->add($phone)->add($email)->add($description)->add($delCode);
}
示例5: buildFilter
public function buildFilter()
{
$listingsId = new Input('listings_id');
$listingsId->getFilterChain()->attach(new StripTags())->attach(new StringTrim())->attach(new StringToLower());
$listingsId->getValidatorChain()->attachByName('Digits');
$deleteCode = new Input('delete_code');
$deleteCode->setAllowEmpty(TRUE);
$deleteCode->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$deleteCode->getValidatorChain()->attachByName('Alnum', array('allowWhiteSpace' => false));
$this->add($listingsId)->add($deleteCode);
}
示例6: getInputFilter
/**
* @return InputFilterInterface
*/
public function getInputFilter()
{
if (!$this->inputFilter) {
$name = new Input('name');
$name->setAllowEmpty(true);
$name->setRequired(false);
$venueId = new Input('venue_id');
$venueId->setRequired(true);
$type = new Input('type');
$type->setRequired(true);
$type->allowEmpty(false);
$url = new Input('url');
$url->setAllowEmpty(true);
$url->setRequired(false);
$startTime = new Input('start_time');
$startTime->setRequired(true);
$startTime->allowEmpty(false);
$endTime = new Input('end_time');
$endTime->setRequired(true);
$endTime->allowEmpty(false);
$startDate = new Input('start_date');
$startDate->setAllowEmpty(false);
$startDate->setRequired(true);
$endDate = new Input('end_date');
$endDate->setRequired(true);
$endDate->allowEmpty(false);
$minimumAge = new Input('minimum_age');
$minimumAge->setRequired(true);
$minimumAge->allowEmpty(false);
$willStop = new Input('will_stop');
$willStop->setRequired(true);
$repetitions = new Input('repetitions');
$repetitions->setAllowEmpty(true);
$repetitions->setRequired(false);
$description = new Input('description');
$description->setAllowEmpty(true);
$description->setRequired(false);
$specialNotes = new Input('special_notes');
$specialNotes->setAllowEmpty(true);
$specialNotes->setRequired(false);
$costs = new Input('costs');
$costs->setAllowEmpty(true);
$costs->setRequired(false);
$contactEmail = new Input('contact_email');
$contactEmail->setRequired(false);
$contactEmail->setAllowEmpty(true)->getValidatorChain()->addValidator(new \Zend\Validator\EmailAddress());
$inputFilter = new InputFilter();
$inputFilter->add($name)->add($type)->add($url)->add($venueId)->add($startTime)->add($endTime)->add($startDate)->add($endDate)->add($willStop)->add($minimumAge)->add($repetitions)->add($specialNotes)->add($description)->add($costs)->add($contactEmail);
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例7: getInputFilter
/**
* Return an instance of InputFilter
*
* @return InputFilter
*/
public function getInputFilter()
{
if (!isset($this->inputFilter)) {
$inputFilter = parent::getInputFilter();
// count
$count = new Input('count');
$count->setAllowEmpty(true);
$count->getFilterChain()->attach(new Int());
$count->getValidatorChain()->attach(new Digits());
$inputFilter->add($count);
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例8: buildFilter
public function buildFilter()
{
$category = new Input('category');
$category->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim')->attachByName('StringToLower');
$category->getValidatorChain()->attachByName('InArray', array('haystack' => $this->getCategories()));
$title = new Input('title');
$title->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$titleRegex = new Regex(array('pattern' => '/^[a-zA-Z0-9 ]*$/'));
$title->getValidatorChain()->attach($titleRegex)->attachByName('StringLength', array('min' => 1, 'max' => 128));
$photo = new Input('photo_filename');
$photo->setRequired(FALSE);
$photo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$photo->getValidatorChain()->attachByName('Regex', array('pattern' => '!^(http(s)?://)?[a-z0-9./_-]+(jp(e)?g|png)$!i'));
$photo->setErrorMessage('Photo must be a URL or a valid filename ending with jpg or png');
$name = new Input('contact_name');
$name->setAllowEmpty(TRUE);
$name->getValidatorChain()->attachByName('Regex', array('pattern' => '/^[a-z0-9. -]{1,255}$/i'));
$name->setErrorMessage('Name should only contain letters, numbers, spaces, . or -.');
$name->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$email = new Input('contact_email');
$email->setAllowEmpty(TRUE);
$email->getValidatorChain()->attachByName('EmailAddress');
$email->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$phone = new Input('contact_phone');
$phone->setAllowEmpty(TRUE);
$phone->getValidatorChain()->attachByName('Regex', array('pattern' => '/^\\+?\\d{1,4}(-\\d{3,4})+$/'));
$phone->setErrorMessage('Phone number must be in the format +nnnn-nnn-nnn-nnnn');
$phone->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$city = new Input('city');
$city->setAllowEmpty(TRUE);
$city->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$city->getValidatorChain()->attachByName('InArray', array('haystack' => PostForm::$cityCodes));
$price = new Input('price');
$price->setAllowEmpty(TRUE);
$price->getValidatorChain()->attachByName('GreaterThan', array('min' => 0.0));
$price->getFilterChain()->attach(new Float());
$expires = new Input('expires');
$expires->setAllowEmpty(TRUE);
$expires->getValidatorChain()->attachByName('InArray', array('haystack' => array_keys($this->getExpireDays())));
$expires->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$deleteCode = new Input('delete_code');
$deleteCode->setRequired(TRUE);
$deleteCode->getValidatorChain()->attachByName('Digits');
$description = new Input('description');
$description->setAllowEmpty(TRUE);
$description->getValidatorChain()->attachByName('StringLength', array('min' => 1, 'max' => 4096));
$description->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$this->add($category)->add($title)->add($photo)->add($name)->add($email)->add($phone)->add($city)->add($price)->add($expires)->add($deleteCode)->add($description);
}
示例9: getInputFilter
/**
* @return InputFilterInterface
*/
public function getInputFilter()
{
if (!$this->inputFilter) {
$searchParam = new Input('search_param');
$searchParam->setRequired(true);
$searchCriteria = new Input('search_criteria');
$searchCriteria->setRequired(true);
$eventId = new Input('event_id');
$eventId->setRequired(false);
$eventId->setAllowEmpty(true);
$inputFilter = new InputFilter();
$inputFilter->add($searchParam)->add($searchCriteria)->add($eventId);
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例10: buildFilter
public function buildFilter()
{
$category = new Input('category');
$category->getFilterChain()->attach(new StripTags())->attach(new StringTrim())->attach(new StringToLower());
$category->getValidatorChain()->attach(new InArray(array('haystack' => $this->categories)));
$title = new Input('title');
$title->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$title->getValidatorChain()->attachByName('Alnum', array('allowWhiteSpace' => TRUE))->attachByName('StringLength', array('options' => array('min' => 6, 'max' => 128)));
$price = new Input('price');
$price->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$priceRegex = new \Zend\Validator\Regex(array('pattern' => '/^[0-9]{1,10}+(\\.[0-9]{1,2})?$/'));
$priceRegex->setMessage('Preço deve ter no máximo 12 caracteres, incluindo opcionalmente 2 casas decimais separadas por ".".');
$price->getValidatorChain()->attach($priceRegex);
$dateExpires = new Input('date_expires');
$dateExpires->setAllowEmpty(TRUE);
$dateExpires->getValidatorChain()->attach(new InArray(array('haystack' => $this->dateExpires)));
$description = new Input('description');
$description->setAllowEmpty(TRUE);
$description->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$description->getValidatorChain()->attachByName('StringLength', array('options' => array('max' => 4096)));
$photoFilename = new Input('photo_filename');
$photoFilename->setAllowEmpty(TRUE);
$photoFilename->getValidatorChain()->attachByName('Regex', array('pattern' => '!^(http://)?[a-z0-9./_-]+(jp(e)?g|png)$!i'));
$photoFilename->setErrorMessage('Photo must be a URL or a valid filename ending with jpg or png');
$contactName = new Input('contact_name');
$contactName->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$contactName->getValidatorChain()->attachByName('Regex', array('pattern' => '/^[a-z0-9., -]{1,255}$/i'));
$contactName->setErrorMessage('Name should only contain letters, numbers, and some punctuation.');
$contactEmail = new Input('contact_email');
$contactEmail->setAllowEmpty(TRUE);
$contactEmail->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$contactEmail->getValidatorChain()->attachByName('EmailAddress');
$contactPhone = new Input('contact_phone');
$contactPhone->setAllowEmpty(TRUE);
$contactPhone->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$contactPhone->getValidatorChain()->attachByName('Regex', array('pattern' => '/^(\\([0-9]{2}\\))\\s([9]{1})?([0-9]{4})-([0-9]{4})$/'));
$contactPhone->setErrorMessage('Contato deve ter o seguinte formato:(99) 9999-9999 ou (99) 99999-9999');
$cityCode = new Input('cityCode');
$cityCode->setAllowEmpty(TRUE);
$cityCode->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$cityCode->getValidatorChain()->attach(new InArray(array('haystack' => array_keys($this->cities))));
$deleteCode = new Input('delete_code');
$deleteCode->setAllowEmpty(TRUE);
$deleteCode->getFilterChain()->attach(new StripTags())->attach(new StringTrim());
$deleteCode->getValidatorChain()->attachByName('Alnum', array('allowWhiteSpace' => TRUE));
$this->add($category)->add($title)->add($price)->add($dateExpires)->add($description)->add($photoFilename)->add($contactName)->add($contactEmail)->add($contactPhone)->add($cityCode)->add($deleteCode);
}
示例11: getInputFilter
public function getInputFilter()
{
if ($this->filter == null) {
$this->filter = new InputFilter();
$inputFilter = parent::getInputFilter();
$email = new Input('email');
$email->setRequired(true);
$email->setAllowEmpty(false);
$objectExists = new ObjectExists(array('object_repository' => $this->objectManager->getRepository(User::getClass()), 'fields' => 'email'));
$objectExists->setMessage($this->translator->translate('forgotPassword.email.notExists'), ObjectExists::ERROR_NO_OBJECT_FOUND);
$emailAddress = new EmailAddress();
$emailAddress->setMessage($this->translator->translate('forgotPassword.email.invalidFormat'), $emailAddress::INVALID_FORMAT);
$email->getValidatorChain()->attach($emailAddress, true)->attach($objectExists);
$this->filter->add($email);
}
return $this->filter;
}
示例12: getInputFilter
public function getInputFilter()
{
$this->filter = parent::getInputFilter();
$moneyValidator = new MoneyValidator();
$delayPercent = new Input('delayPercent');
$delayPercent->setRequired(false);
$delayPercent->setAllowEmpty(true);
$delayPercent->getValidatorChain()->attach($moneyValidator);
$this->filter->add($delayPercent);
$digits = new Digits();
$deadlineDays = new Input('deadlineDays');
$deadlineDays->setRequired(false);
$deadlineDays->setAllowEmpty(true);
$deadlineDays->getValidatorChain()->attach($digits);
$this->filter->add($deadlineDays);
return $this->filter;
}
示例13: createService
/**
* @param ServiceLocatorInterface $serviceLocator
*
* @return InputFilter
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$username = new Input();
$username->setName('username');
$username->setRequired(true);
$username->setAllowEmpty(false);
$username->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$password = new Input();
$password->setName('password');
$password->setRequired(true);
$password->setAllowEmpty(false);
$password->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$password->getValidatorChain()->attach($serviceLocator->get('UghAuthentication\\Authentication\\Validator\\Authentication'));
$inputFilter = new InputFilter();
$inputFilter->add($username);
$inputFilter->add($password);
return $inputFilter;
}
示例14: getInputFilter
/**
* @return InputFilterInterface
*/
public function getInputFilter()
{
if (!$this->inputFilter) {
$name = new Input('name');
$name->setRequired(true);
$address1 = new Input('address_1');
$address1->setRequired(true);
$address2 = new Input('address_2');
$address2->setAllowEmpty(true);
$address2->setRequired(false);
$city = new Input('city');
$city->setRequired(true);
$state = new Input('state');
$state->setRequired(false);
$state->setAllowEmpty(true);
$country = new Input('country');
$country->setRequired(true);
$postalCode = new Input('postal_code');
$postalCode->setRequired(false);
$postalCode->setAllowEmpty(true);
$url = new Input('url');
$url->setAllowEmpty(true);
$url->setRequired(false);
$specialNotes = new Input('special_notes');
$specialNotes->setAllowEmpty(true);
$specialNotes->setRequired(false);
$description = new Input('description');
$description->setAllowEmpty(true);
$description->setRequired(false);
$minimumAge = new Input('minimum_age');
$minimumAge->setRequired(true);
$contactEmail = new Input('contact_email');
$contactEmail->setAllowEmpty(true);
$contactEmail->setRequired(false)->getValidatorChain()->addValidator(new \Zend\Validator\EmailAddress());
$type = new Input('type');
$type->setRequired(true);
$inputFilter = new InputFilter();
$inputFilter->add($name)->add($address1)->add($address2)->add($city)->add($state)->add($country)->add($postalCode)->add($url)->add($description)->add($specialNotes)->add($minimumAge)->add($contactEmail)->add($type);
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例15: getInputFilter
public function getInputFilter()
{
if ($this->filter == null) {
$this->filter = new InputFilter();
$code = new Input('code');
$code->setRequired(false);
$code->setAllowEmpty(true);
$this->filter->add($code);
$digits = new Digits();
$value = new Input('value');
$value->setRequired(false);
$value->setAllowEmpty(true);
$value->getValidatorChain()->attach($digits);
$this->filter->add($value);
$comment = new Input('comment');
$comment->setRequired(false);
$comment->setAllowEmpty(true);
$this->filter->add($comment);
}
return $this->filter;
}