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


PHP Form::setInputFilter方法代码示例

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


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

示例1: testCallingPrepareEnsuresInputFilterRetrievesDefaults

    public function testCallingPrepareEnsuresInputFilterRetrievesDefaults()
    {
        $element = new TestAsset\ElementWithFilter('foo');
        $filter  = new InputFilter();
        $this->form->setInputFilter($filter);
        $this->form->add($element);
        $this->form->prepare();

        $this->assertTrue($filter->has('foo'));
        $input = $filter->get('foo');
        $filters = $input->getFilterChain();
        $this->assertEquals(1, count($filters));
        $validators = $input->getValidatorChain();
        $this->assertEquals(2, count($validators));
        $this->assertTrue($input->isRequired());
        $this->assertEquals('foo', $input->getName());

        // Issue #2586 Ensure default filters aren't added twice
        $filter = $this->form->getInputFilter();

        $this->assertTrue($filter->has('foo'));
        $input = $filter->get('foo');
        $filters = $input->getFilterChain();
        $this->assertEquals(1, count($filters));
        $validators = $input->getValidatorChain();
        $this->assertEquals(2, count($validators));
    }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:27,代码来源:FormTest.php

示例2: testPreserveEntitiesBoundToCollectionAfterValidation

 public function testPreserveEntitiesBoundToCollectionAfterValidation()
 {
     $this->form->setInputFilter(new \Zend\InputFilter\InputFilter());
     $fieldset = new TestAsset\ProductCategoriesFieldset();
     $fieldset->setUseAsBaseFieldset(true);
     $product = new Entity\Product();
     $product->setName('Foobar');
     $product->setPrice(100);
     $c1 = new Entity\Category();
     $c1->setId(1);
     $c1->setName('First Category');
     $c2 = new Entity\Category();
     $c2->setId(2);
     $c2->setName('Second Category');
     $product->setCategories(array($c1, $c2));
     $this->form->add($fieldset);
     $this->form->bind($product);
     $data = array('product' => array('name' => 'Barbar', 'price' => 200, 'categories' => array(array('name' => 'Something else'), array('name' => 'Totally different'))));
     $hash1 = spl_object_hash($this->form->getObject()->getCategory(0));
     $this->form->setData($data);
     $this->form->isValid();
     $hash2 = spl_object_hash($this->form->getObject()->getCategory(0));
     // Returned object has to be the same as when binding or properties
     // will be lost. (For example entity IDs.)
     $this->assertTrue($hash1 == $hash2);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:26,代码来源:FormTest.php

示例3: getModel

 protected function getModel()
 {
     // Dependências
     $form = new Form();
     $inputFilter = new InputFilter();
     $formSearch = new Form();
     $inputFilterSearch = new InputFilter();
     $persistence = $this->getMock('Balance\\Model\\Persistence\\PersistenceInterface');
     // Parâmetro
     $form->add(new Text('id'));
     $inputFilter->add(new Input('id'));
     // Parâmetro
     $form->add(new Text('foo'));
     $inputFilter->add(new Input('foo'));
     // Pesquisa: Palavras Chave
     $formSearch->add(new Text('keywords'));
     $inputFilterSearch->add(new Input('keywords'));
     // Configurações
     $form->setInputFilter($inputFilter);
     $formSearch->setInputFilter($inputFilterSearch);
     // Inicialização
     $model = new Model($persistence);
     // Formulários
     $model->setForm($form)->setFormSearch($formSearch);
     // Apresentação
     return $model;
 }
开发者ID:wandersonwhcr,项目名称:balance,代码行数:27,代码来源:ModelTest.php

示例4: getForm

 public function getForm(array $urlType)
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new Form();
     $form->setAttribute('class', 'form-horizontal');
     $form->setAttribute('role', 'form');
     $form->add(array('name' => 'menuId', 'type' => 'Hidden'));
     $form->add(array('name' => 'title', 'type' => 'text', 'options' => array('label' => 'Title'), 'attributes' => array('class' => 'form-control')));
     $form->add(array('name' => 'description', 'type' => 'Textarea', 'options' => array('label' => 'Description'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'description')));
     $form->add(array('name' => 'icon', 'type' => 'text', 'options' => array('label' => 'Icon'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Icon Class')));
     $form->add(array('name' => 'url', 'type' => 'text', 'options' => array('label' => 'Url'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Url')));
     $url_type = new Select('url_type');
     $url_type->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($urlType)->setEmptyOption('-- Choose URL Type --');
     $form->add($url_type);
     $hasDivider = new Checkbox('hasDivider');
     $hasDivider->setLabel('Has divider?');
     $form->add($hasDivider);
     $form->add(array('name' => 'parentId', 'type' => 'hidden'));
     $form->add(array('name' => 'priority', 'type' => 'number', 'options' => array('label' => 'Priority'), 'attributes' => array('class' => 'form-control')));
     $form->setInputFilter($this->getInputFilter());
     $this->form = $form;
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:25,代码来源:MenuHelper.php

示例5: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form();
     $form->add(['name' => 'name', 'options' => ['label' => 'Name'], 'attributes' => ['type' => 'text']]);
     $form->add(['name' => 'description', 'options' => ['label' => 'Description'], 'attributes' => ['type' => 'textarea']]);
     $form->add(['name' => 'location', 'options' => ['label' => 'Location'], 'attributes' => ['type' => 'text']]);
     $form->setHydrator(new ClassMethods());
     $form->setInputFilter($this->getInputFilter());
     return $form;
 }
开发者ID:WeCamp,项目名称:Meetspire,代码行数:16,代码来源:GroupFormFactory.php

示例6: inAction

 public function inAction()
 {
     //check for the existence of any users, and if none, it means it is a new installation, then redirect to user registration
     $entityManager = $this->getServiceLocator()->get('entity-manager');
     $countAdministrators = $entityManager->getRepository(get_class(new User()))->countAdminUsers();
     if (!$countAdministrators) {
         $this->flashMessenger()->addInfoMessage('Here you can create the first user for the system');
         return $this->redir()->toRoute('admin/default', ['controller' => 'log', 'action' => 'initial']);
     }
     $uname = new Element\Text('uname');
     $uname->setLabel('User name');
     $uname->setAttribute('required', 'required');
     $password = new Element\Password('password');
     $password->setLabel('Password');
     $password->setAttribute('required', 'required');
     $form = new Form('login');
     $form->add($uname)->add($password);
     $unameInput = new Input('uname');
     $unameInput->getFilterChain()->attachByName('StringTrim');
     $passwordInput = new Input('password');
     $inputFilter = new InputFilter();
     $inputFilter->add($unameInput)->add($passwordInput);
     $form->setInputFilter($inputFilter);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $uname = $form->get('uname')->getValue();
             $password = $form->get('password')->getValue();
             $auth = $this->getServiceLocator()->get('auth');
             $authAdapter = $auth->getAdapter();
             $authAdapter->setIdentity($uname);
             $authAdapter->setCredential($password);
             $result = $auth->authenticate();
             $user = $result->getIdentity();
             if ($result->isValid()) {
                 $this->flashMessenger()->addSuccessMessage(sprintf($this->translator->translate("Welcome %s. You have been logged in successfully"), $user->getUname()));
                 return $this->redir()->toRoute('admin/default', array('controller' => 'index'));
             } else {
                 $this->flashMessenger()->addErrorMessage($this->translator->translate('Wrong details'));
                 $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'in'));
             }
         }
     }
     return array('form' => $form);
 }
开发者ID:veniva,项目名称:zcms,代码行数:46,代码来源:LogController.php

示例7: getForm

 public function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new Form();
     $form->setAttribute('class', 'form-horizontal');
     $form->setAttribute('role', 'form');
     $form->add(array('name' => 'roleId', 'type' => 'Hidden'));
     $form->add(array('name' => 'name', 'type' => 'text', 'options' => array('label' => 'Title'), 'attributes' => array('class' => 'form-control')));
     $form->add(array('name' => 'description', 'type' => 'Textarea', 'options' => array('label' => 'Description'), 'attributes' => array('class' => 'form-control')));
     $form->add(array('name' => 'icon', 'type' => 'text', 'attributes' => array('class' => 'form-control', 'placeholder' => 'Icon Class')));
     $form->add(array('name' => 'parentId', 'type' => 'Hidden'));
     $form->add(array('name' => 'priority', 'type' => 'number', 'options' => array('label' => 'Priority'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Choose priority')));
     $form->setInputFilter($this->getInputFilter());
     $this->form = $form;
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:18,代码来源:RoleHelper.php

示例8: write

 /**
  * {@inheritdoc}
  *
  * @param \Dms\Document\Document $document
  *
  * @see \Dms\Storage\StorageInterface::write()
  */
 public function write(\Dms\Document\Document $document)
 {
     $ret = null;
     $name = $document->getId();
     $nameMod = substr($name, 4);
     $f = substr($name, 0, 2) . '/' . substr($name, 2, 2) . '/';
     $path = $this->getBasePath() . $f;
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     $p = $path . $nameMod . '.dat';
     if ($document->getSupport() === Document::SUPPORT_FILE_MULTI_PART_STR) {
         $fileInput = new FileInput(key($document->getDatas()));
         $fileInput->getFilterChain()->attachByName('filerenameupload', ['target' => $p]);
         $inputFilter = new InputFilter();
         $inputFilter->add($fileInput);
         $form = new Form();
         $form->setInputFilter($inputFilter);
         $form->setData($document->getDatas());
         if ($form->isValid()) {
             $form->getData();
         }
     } else {
         $fp = fopen($p, 'w');
         fwrite($fp, $document->getDatas());
         $document->setWeight(strlen($document->getDatas()));
         fclose($fp);
     }
     $conf_storage = $this->options->getStorage();
     if (isset($conf_storage['name']) && $conf_storage['name'] === 's3') {
         print_r($_FILES);
         $this->s3Client->copyObject(['Bucket' => $conf_storage['bucket'], 'Key' => $f . $nameMod . '.dat', 'CopySource' => $conf_storage['bucket'] . '/' . $f . $nameMod . '.dat', 'ContentType' => $document->getType(), 'ContentDisposition' => sprintf('filename=%s', null === $document->getName() ? substr($file, -1 * strlen($document->getFormat())) === $document->getFormat() ? $file : $file . '.' . $document->getFormat() : $document->getName()), 'MetadataDirective' => 'REPLACE']);
     }
     $document->setSupport(Document::SUPPORT_FILE_STR);
     $this->getEventManager()->trigger(__FUNCTION__, $this, array('path' => $path, 'short_name' => $nameMod, 'all_path' => $path . $nameMod . '.dat', 'support' => $document->getSupport(), 'name' => $name));
     $serialize = serialize($document);
     $fp = fopen($path . $nameMod . '.inf', 'w');
     $ret += fwrite($fp, $serialize);
     fclose($fp);
     $this->getEventManager()->trigger(__FUNCTION__, $this, array('path' => $path, 'short_name' => $nameMod, 'all_path' => $path . $nameMod . 'inf', 'support' => $document->getSupport(), 'name' => $name));
     return $ret;
 }
开发者ID:buse974,项目名称:dms,代码行数:49,代码来源:Storage.php

示例9: __invoke

 public function __invoke($action = 'view')
 {
     $this->parentLocator = $this->getServiceLocator()->getServiceLocator();
     $this->router = $this->parentLocator->get('Router');
     $p = $this->routeMatch->getParams();
     $c = $p['controller'];
     $n = $this->getModuleName($c);
     $v = $this->getView();
     $r = $this->routeMatch->getMatchedRouteName();
     $em = $this->getEntityManager();
     $objRepository = $em->getRepository($this->getEntityClass($p['controller']));
     $i = new InputFilter();
     $i->add(array('name' => 'entitynav', 'required' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim'))));
     $form = new Form('entitynav');
     $form->setAttribute('method', 'POST');
     $form->setAttribute('action', $v->url('navigation'));
     $form->add(array('name' => 'params[id]', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'required' => false, 'allow_empty' => true, 'filters' => array(array('name' => 'Zend\\Filter\\StringTrim')), 'options' => array('label_attributes' => array('class' => 'sr-only'), 'empty_option' => 'Switch ' . $n . '(s)', 'object_manager' => $em, 'target_class' => $this->getEntityClass($c), 'is_method' => true, 'find_method' => array('name' => 'findAll')), 'attributes' => array('id' => strtolower($n) . 'id', 'onChange' => 'if (this.value) this.form.submit()', 'value' => isset($p['id']) ? $p['id'] : "")));
     $form->add(array('name' => 'controller', 'type' => 'hidden', 'attributes' => array('value' => $p['controller'])));
     $form->add(array('name' => 'params[action]', 'type' => 'hidden', 'attributes' => array('value' => $this->hasAction($action) ? $action : $p['action'])));
     $form->add(array('name' => 'route', 'type' => 'hidden', 'attributes' => array('value' => $this->findRoute($action))));
     $form->setInputFilter($i);
     echo $this->helperExists('losForm') ? $v->losForm($form, false) : $v->form($form);
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:23,代码来源:EntityNavSelect.php

示例10: getPasswordForm

 protected function getPasswordForm()
 {
     $translator = $this->getServiceLocator()->get('translator');
     $form = new Form('password');
     $form->setAttribute('class', 'form-horizontal')->add(array('name' => 'oldPassword', 'type' => 'password', 'options' => array('label' => $translator->translate('Old password')), 'attributes' => array('class' => 'form-control input-sm')))->add(array('name' => 'password', 'type' => 'password', 'options' => array('label' => $translator->translate('New password')), 'attributes' => array('class' => 'form-control input-sm')))->add(array('name' => 'password_confirm', 'type' => 'password', 'options' => array('label' => $translator->translate('Confirm password')), 'attributes' => array('class' => 'form-control input-sm')))->add(array('name' => 'save', 'type' => 'submit', 'attributes' => array('value' => 'Save', 'class' => 'btn btn-sm btn-success')));
     $filter = new InputFilter();
     $filter->add(array('name' => 'password', 'required' => true))->add(array('name' => 'oldPassword', 'required' => true))->add(array('name' => 'password_confirm', 'required' => false, 'validators' => array(array('name' => 'Identical', 'options' => array('token' => 'password')))));
     $form->setInputFilter($filter);
     return $form;
 }
开发者ID:cvsolutions,项目名称:ZfcUserCrud,代码行数:10,代码来源:CrudController.php

示例11: getForm

 private function getForm()
 {
     $translator = $this->getServiceLocator()->get('translator');
     $config = $this->getServiceLocator()->get('zfcusercrud_options');
     $role = new $config['roleEntity']();
     $form = new Form('role');
     $form->setAttribute('class', 'form-horizontal')->setHydrator(new DoctrineHydrator($this->getOM()))->setObject($role)->add(array('name' => 'roleId', 'options' => array('label' => $translator->translate('Role')), 'attributes' => array('class' => 'form-control input-sm')))->add(array('name' => 'parent', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'options' => array('label' => $translator->translate('Parent Role'), 'object_manager' => $this->getOM(), 'target_class' => $config['roleEntity'], 'property' => 'roleId', 'empty_option' => 'None')))->add(array('name' => 'save', 'type' => 'submit', 'attributes' => array('value' => 'Save', 'class' => 'btn btn-sm btn-success')));
     $filter = new InputFilter();
     $filter->add(array('name' => 'roleId', 'required' => true))->add(array('name' => 'parent', 'required' => false));
     $form->setInputFilter($filter);
     return $form;
 }
开发者ID:cvsolutions,项目名称:ZfcUserCrud,代码行数:12,代码来源:RoleController.php

示例12: changePasswordAction

 public function changePasswordAction()
 {
     $viewModel = new ViewModel();
     $username = $this->getAuthService()->getIdentity()->getUsername();
     $registerForm = new RegisterForm();
     $form = new \Zend\Form\Form('changePasswordForm');
     $form->add($registerForm->get('password'));
     $form->add($registerForm->get('re_password'));
     //  $form->add($registerForm->get('submit')->setAttribute('value', '修改密碼'));
     $accountFilter = new AccountFIlter();
     $filter = new InputFilter();
     $filter->add($accountFilter->get('password'))->add($accountFilter->get('re_password'));
     $form->setInputFilter($filter);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $form->setData($data);
         if ($form->isValid()) {
             $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
             $user = $em->getRepository('Base\\Entity\\User')->findOneBy(array('username' => $username));
             if ($user) {
                 //$user->setPassword(md5($form->get('password')->getValue()));
                 $user->setPassword(\Zend\Ldap\Attribute::createPassword($form->get('password')->getValue()));
                 $em->persist($user);
                 $em->flush();
                 $this->getServiceLocator()->get('Zend\\Log')->info($username . ' changed password');
                 $this->flashMessenger()->addSuccessMessage('更改密碼成功!');
                 return $this->redirect()->refresh();
             }
         }
     }
     $viewModel->setVariable('form', $form);
     return $viewModel;
 }
开发者ID:hamichen,项目名称:CMS,代码行数:33,代码来源:SetController.php

示例13: render


//.........这里部分代码省略.........
         }
         if (isset($element->line_paragraph)) {
             $attributes = $element->line_paragraph[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             $required = $attributes->data->required == 'true' ? true : false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Textarea($name);
             $element->setName($label);
             $element->setLabel($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_upload)) {
             $attributes = $element->line_upload[0];
             //print_r($attributes);
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             $required = $attributes->data->required == 'true' ? true : false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $filesizeMin = isset($attributes->data->filesize) ? $attributes->data->filesize->min : '';
             $filesizeMax = isset($attributes->data->filesize) ? $attributes->data->filesize->max : '';
             $element = new Element\File($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'validators' => array(array('name' => '\\Zend\\Validator\\File\\Size', 'options' => array('max' => 10 * 1024 * 1024)), array('name' => '\\Zend\\Validator\\File\\Extension', 'options' => array('png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF', 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'Veuillez télécharger une image')))))));
         }
         if (isset($element->line_radio)) {
             $attributes = $element->line_radio[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array();
             $element = new Element\Radio($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($innerData as $value) {
                 $values[] = $value->label;
             }
             $element->setValueOptions($values);
             $form->add($element);
         }
         if (isset($element->line_dropdown)) {
             $attributes = $element->line_dropdown[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $dropdownValues = isset($attributes->data->dropdownValues) ? $attributes->data->dropdownValues : array();
             $element = new Element\Select($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($dropdownValues as $value) {
                 $values[] = $value->dropdown_label;
             }
             $element->setValueOptions($values);
             $form->add($element);
         }
     }
     $form->setInputFilter($inputFilter);
     return $form;
 }
开发者ID:arnaud-hours,项目名称:PlaygroundCore,代码行数:101,代码来源:Formgen.php

示例14: setInputFilter

 /**
  * {@inheritDoc}
  */
 public function setInputFilter(InputFilterInterface $inputFilter)
 {
     $this->inputFilterPrototype = $inputFilter;
     $this->hasMergedInputFilter = false;
     return parent::setInputFilter($inputFilter);
 }
开发者ID:coolms,项目名称:common,代码行数:9,代码来源:Form.php

示例15: buildForm

 /**
  * @param bool $create
  * @return Form
  */
 public function buildForm($create = true)
 {
     $attributes = $this->getHeaders();
     $form = new Form();
     $filter = new InputFilter();
     $validators = array();
     foreach ($attributes as $key => $attribute) {
         $label = isset($attribute['title']) ? $attribute['title'] : ucwords($key);
         $type = isset($attribute['type']) ? $attribute['type'] : 'text';
         switch ($type) {
             case 'text':
                 $element = new Element\Text($key);
                 break;
             case 'int':
                 $element = new Element\Text($key);
                 $validators[] = 'Zend\\Validator\\Digits';
                 $type = 'text';
                 break;
             case 'float':
                 $element = new Element\Text($key);
                 $validators[] = 'Zend\\I18n\\Validator\\Float';
                 $type = 'text';
                 break;
             case 'password':
                 $element = new Element\Password($key);
                 break;
             case 'select':
                 $element = new Element\Select($key);
                 break;
             case 'radio':
                 $element = new Element\Radio($key);
                 break;
             case 'hidden':
                 $element = new Element\Hidden($key);
                 break;
             case 'checkbox':
                 $element = new Element\Checkbox($key);
                 break;
             case 'textarea':
                 $element = new Element\Textarea($key);
                 break;
             case 'wysiwyg':
                 $element = new Element\Textarea($key);
                 break;
             default:
                 $element = new Element($key);
         }
         if ($create === true) {
             if (isset($attribute['create']) && $attribute['create'] === false) {
                 continue;
             }
         } else {
             if (isset($attribute['update']) && $attribute['update'] === false) {
                 continue;
             }
         }
         $element->setLabel($label);
         $element->setAttributes(array('type' => $type));
         if (isset($attribute['options'])) {
             $element->setOptions(array('value_options' => $attribute['options']));
         }
         if (isset($attribute['required']) && $attribute['required'] === true) {
             $validators[] = 'Zend\\Validator\\NotEmpty';
         }
         if (!empty($validators)) {
             foreach ($validators as $validator) {
                 $input = new Input($key);
                 $input->getValidatorChain()->attach(new $validator());
                 $filter->add($input);
             }
         }
         $form->setInputFilter($filter);
         $form->add($element);
     }
     $element = new Element($key);
     $element->setAttributes(array('type' => 'button', 'value' => '<span class="glyphicon glyphicon-chevron-left"></span> Back', 'name' => 'btnBack'));
     $form->add($element);
     $element = new Element($key);
     $element->setAttributes(array('type' => 'submit', 'value' => 'Submit', 'name' => 'btnSubmit'));
     $form->add($element);
     $form->add(array('type' => 'Zend\\Form\\Element\\Csrf', 'name' => 'csrf'));
     return $form;
 }
开发者ID:zf-hipsters,项目名称:crud-factory,代码行数:87,代码来源:CrudFactory.php


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