当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::getInputFilter方法代码示例

本文整理汇总了PHP中Zend\Form\Form::getInputFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getInputFilter方法的具体用法?PHP Form::getInputFilter怎么用?PHP Form::getInputFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\Form的用法示例。


在下文中一共展示了Form::getInputFilter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNoteForm

 /**
  * @param Entity\Note $note
  * @param string $url
  * @param string $action
  * @param array $members
  * @return \Zend\Form\Form
  */
 public function getNoteForm(Entity\Note $note, $url = '', $action = 'add', $members = null)
 {
     if (is_null($this->noteForm)) {
         $builder = new AnnotationBuilder($this->getEntityManager());
         $this->noteForm = $builder->createForm($note);
         $this->noteForm->setAttribute('action', $url);
         $this->noteForm->setAttribute('id', 'noteForm');
         $this->noteForm->setHydrator(new DoctrineObject($this->getEntityManager(), 'Secretary\\Entity\\Note'));
         $this->noteForm->bind($note);
         if ($action == 'edit' && $note->getPrivate() === false) {
             $this->noteForm->remove('private');
             $group = $note->getGroup();
             $membersString = $this->getMembersString(array_keys($members));
             $this->noteForm->get('groupHidden')->setValue($group->getId());
             $this->noteForm->get('members')->setValue($membersString);
             $this->noteForm->getInputFilter()->remove('__initializer__');
             $this->noteForm->getInputFilter()->remove('__cloner__');
             $this->noteForm->getInputFilter()->remove('__isInitialized__');
             $this->noteForm->getInputFilter()->remove('lazyPropertiesDefaults');
         } else {
             $this->noteForm->get('private')->setAttribute('required', false);
             $this->noteForm->getInputFilter()->get('private')->setRequired(false);
         }
     }
     return $this->noteForm;
 }
开发者ID:dotuancd,项目名称:secretary,代码行数:33,代码来源:Note.php

示例2: configureInputFilter

 /**
  * @param Collection $collection
  */
 protected function configureInputFilter(Collection $collection)
 {
     // Make it a collection input filter
     $inputFilter = new CollectionInputFilter();
     $inputFilter->setIsRequired(false);
     // Add the input filter of the target document as the real input filter:
     $targetElement = $collection->getTargetElement();
     if ($targetElement instanceof InputFilterProviderInterface) {
         $configuredFilter = $targetElement->getInputFilterSpecification();
         $inputFilter->setInputFilter($configuredFilter);
     }
     // Replace the current input filter in the actual form:
     $collectionName = $collection->getName();
     $formFilter = $this->form->getInputFilter();
     $formFilter->remove($collectionName);
     $formFilter->add($inputFilter, $collectionName);
 }
开发者ID:phpro,项目名称:zf-annotated-forms,代码行数:20,代码来源:ConfigureCollectionInputFilterListener.php

示例3: testAddNonBaseFieldsetObjectInputFilterToFormInputFilter

 public function testAddNonBaseFieldsetObjectInputFilterToFormInputFilter()
 {
     $fieldset = new Fieldset('foobar');
     $fieldset->add(new Element('foo'));
     $fieldset->setUseAsBaseFieldset(false);
     $this->form->add($fieldset);
     $inputFilterFactory = new InputFilterFactory();
     $inputFilter = $inputFilterFactory->createInputFilter(array('foo' => array('name' => 'foo', 'required' => true)));
     $model = new TestAsset\ValidatingModel();
     $model->setInputFilter($inputFilter);
     $this->form->bind($model);
     $this->assertInstanceOf('Zend\\InputFilter\\InputFilterInterface', $this->form->getInputFilter()->get('foobar'));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:13,代码来源:FormTest.php

示例4: getInputFilter

 public function getInputFilter()
 {
     parent::getInputFilter();
     if (!$this->filter) {
         $inputFilter = new InputFilter();
         $inputFactory = new InputFactory();
         $inputFilter->add($inputFactory->createInput(array('name' => 'name', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => '"Name" is required')))))));
         $inputFilter->add($inputFactory->createInput(array('name' => 'email', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'EmailAddress', 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Email format is not valid'))), array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => '"Email" is required')))))));
         $inputFilter->add($inputFactory->createInput(array('name' => 'inquiry', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => '"Question" is required')))))));
         $this->filter = $inputFilter;
     }
     return $this->filter;
 }
开发者ID:veniva,项目名称:zcms,代码行数:13,代码来源:Contact.php

示例5: getInputFilter

 public function getInputFilter()
 {
     parent::getInputFilter();
     if ($this->filter == null) {
         $this->filter = new InputFilter();
         $this->filter->add(array("name" => "firstname", "required" => true, 'validators' => array(array('name' => 'Alpha', 'options' => array("allowWhiteSpace" => true)), array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 3, 'max' => 50)))));
         $this->filter->add(array("name" => "lastname", "required" => true, 'validators' => array(array('name' => 'Alpha', 'options' => array("allowWhiteSpace" => true)), array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 3, 'max' => 50)))));
         $this->filter->add(array("name" => "email", "required" => true, "validators" => array(array("name" => 'EmailAddress'))));
         $this->filter->add(array('name' => "phone", "required" => true, 'validators' => array(array('name' => 'regex', 'options' => array("pattern" => '/^[0-9]{8,15}$/', "message" => "numero invalide")))));
         $this->filter->add(array('name' => 'password', 'validators' => array(array('name' => 'StringLength', 'options' => array('min' => 6, 'max' => 50)))));
     }
     return $this->filter;
 }
开发者ID:jkhaled,项目名称:bms,代码行数:13,代码来源:RegisterForm.php

示例6: getInputFilter

 public function getInputFilter()
 {
     $formInputFilter = parent::getInputFilter();
     //email should not exists (register)
     $emailInput = $formInputFilter->get('user')->get('email');
     $emailUnique = new \DoctrineModule\Validator\NoObjectExists(array('object_manager' => $this->em, 'object_repository' => $this->em->getRepository('CasasoftAuth\\Entity\\User'), 'fields' => 'email'));
     $emailUnique->setMessage('Diese E-Mail-Adresse wird bereits verwendet.', 'objectFound');
     $emailInput->getValidatorChain()->attach($emailUnique);
     $usernameInput = $formInputFilter->get('user')->get('username');
     $usernameUnique = new \DoctrineModule\Validator\NoObjectExists(array('object_manager' => $this->em, 'object_repository' => $this->em->getRepository('CasasoftAuth\\Entity\\User'), 'fields' => 'username'));
     $usernameUnique->setMessage('Dieser Benutzername wird bereits verwendet.', 'objectFound');
     $usernameInput->getValidatorChain()->attach($usernameUnique);
     return $formInputFilter;
 }
开发者ID:omusico,项目名称:casawp,代码行数:14,代码来源:UserRegisterForm.php

示例7: getInputFilter

 /**
  * Since the input filter was set how I want when adding the captcha element,
  * and I want to adjust the other default filters, I have overriden this method.
  * Not sure how I feel about it.
  *
  * @param void
  * @return Zend\InputFilter\InputFilter
  * @override
  * @todo Fix this up
  **/
 public function getInputFilter()
 {
     if ($this->_filter == null) {
         $filter = parent::getInputFilter();
         //What the h4ck!?  Maybe I can just modify these filters instead of re-adding them?
         $filter->remove('name')->remove('email')->remove('comment');
         $factory = new InputFactory();
         $filter->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' => 50))))));
         $filter->add($factory->createInput(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'EmailAddress', 'options' => array('message' => array('Please enter a valid email address.  Thanks!'))), array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 1, 'max' => 100))))));
         $filter->add($factory->createInput(array('name' => 'comment', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 1, 'max' => 3000))))));
         $this->_filter = $filter;
     }
     return $this->_filter;
 }
开发者ID:rkeplin,项目名称:zf2-d2-blog,代码行数:24,代码来源:ContactForm.php

示例8: 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;
 }
开发者ID:kristjanAnd,项目名称:SimpleIV,代码行数:17,代码来源:ForgotPassword.php

示例9: buildForm

 protected function buildForm()
 {
     $form = new Form();
     $parameters = $this->getUserParameters();
     // add the elements to the form
     foreach ($parameters as $parameter) {
         $element = $this->buildElement($parameter);
         $form->add($element);
     }
     // modify the input filter
     foreach ($parameters as $parameter) {
         $filter = $form->getInputFilter()->get($parameter->name);
         $filter->setAllowEmpty($parameter->isAllowBlank());
     }
     $submit = new \Zend\Form\Element\Submit('ViewReportControl');
     $submit->setValue('View Report');
     $form->add($submit);
     $this->form = $form;
     return $this;
 }
开发者ID:caseypage,项目名称:php-ssrs-1,代码行数:20,代码来源:ZendFramework2.php

示例10: resetAction

 public function resetAction()
 {
     $request = $this->getRequest();
     $email = urldecode($request->getQuery()->email);
     $token = $request->getQuery()->token;
     if (empty($email) || empty($token)) {
         $this->flashMessenger()->addErrorMessage($this->translator->translate('The link you\'re using is broken'));
         return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'in'));
     }
     $sl = $this->getServiceLocator();
     $entityManager = $sl->get('entity-manager');
     //check if the token is valid
     $passwordResetClassName = get_class(new PasswordResets(null, null));
     $resetPassword = $entityManager->find($passwordResetClassName, ['email' => $email, 'token' => $token]);
     if (!$resetPassword) {
         $this->flashMessenger()->addErrorMessage($this->translator->translate('The link you\'re using is out of date or corrupted, please create another password request'));
         return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'forgotten'));
     }
     $createdAt = $resetPassword->getCreatedAt();
     $date = new \DateTime();
     $date->sub(new \DateInterval('PT24H'));
     if ($date > $createdAt) {
         $this->flashMessenger()->addErrorMessage($this->translator->translate('The link you\'re using is out of date, please create another password request'));
         return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'forgotten'));
     }
     $userClassEntity = $sl->get('user-entity');
     $user = $entityManager->getRepository(get_class($userClassEntity))->findOneByEmail('ven.iv@gmx.com');
     if (!$user) {
         $this->flashMessenger()->addErrorMessage($this->translator->translate('There is no user with email: ' . $email . '. You have probably changed the email recently.'));
         return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'forgotten'));
     }
     $form = new Form('reset_password');
     $form->add(array('type' => 'Admin\\Form\\UserPassword', 'name' => 'password_fields'));
     $form->add(array('name' => 'submit', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('value' => 'Edit')));
     $form->getInputFilter()->get('password_fields')->get('password_repeat')->setRequired(true);
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $user->setUpass($form->getInputFilter()->get('password_fields')->get('password')->getValue());
             $entityManager->getRepository($passwordResetClassName)->deleteAllForEmail($email);
             $entityManager->flush();
             $this->flashMessenger()->addSuccessMessage($this->getTranslator()->translate('The password has been changed successfully.'));
             $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'in'));
         }
     }
     return ['form' => $form];
 }
开发者ID:veniva,项目名称:zcms,代码行数:47,代码来源:LogController.php


注:本文中的Zend\Form\Form::getInputFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。