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


PHP Form::add方法代码示例

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


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

示例1: getStep

 /**
  * Get step model
  *
  * @param string $step
  * @return \Core\View\Model\WizardStep
  */
 protected function getStep($step)
 {
     $store = $this->getStore();
     $formSrv = $this->getServiceLocator()->get('Form');
     if ($step == $this->startStep) {
         $form = $formSrv->get('Grid\\Paragraph\\CreateWizard\\Start');
         $model = new StartStep(array('textDomain' => 'paragraph'));
     } else {
         $store['type'] = $step;
         $form = new Form();
         $create = $formSrv->get('Grid\\Paragraph\\Meta\\Create');
         $model = new WizardStep(array('textDomain' => 'paragraph'), array('finish' => true, 'next' => 'finish'));
         if ($create->has($step)) {
             foreach ($create->get($step) as $element) {
                 $form->add($element);
             }
         } else {
             $edit = $formSrv->get('Grid\\Paragraph\\Meta\\Edit');
             if ($edit->has($step)) {
                 foreach ($edit->get($step) as $element) {
                     $form->add($element);
                 }
             } else {
                 $model->setOption('skip', true);
             }
         }
     }
     return $model->setStepForm($form);
 }
开发者ID:gridguyz,项目名称:core,代码行数:35,代码来源:CreateWizardController.php

示例2: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form();
     $form->add(new \MiniModule\Form\Element\Login(), array('priority' => 1));
     $form->add(new Submit('submit'));
     return $form;
 }
开发者ID:sanPgut,项目名称:SupportCoursZF2,代码行数:7,代码来源:AuthentificationFormFactory.php

示例3: getForm

 public function getForm($hasCaptcha, $url = '', $captchaPath = '')
 {
     if (!$this->form) {
         $form = new Form();
         $txtUser = new Element\Text('username');
         $txtUser->setLabel('User Name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'User name');
         $password = new Element\Password('password');
         $password->setLabel('Password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Password');
         $remember = new Element\Checkbox('remember');
         $remember->setLabel('Save authentication?')->setAttribute('class', 'form-control');
         if ($hasCaptcha) {
             $captchaImage = new Image();
             $captchaImage->setFont('./data/font/CAMBRIA.TTC')->setWidth(200)->setHeight(60)->setDotNoiseLevel(40)->setLineNoiseLevel(4)->setExpiration(90);
             $captchaImage->setImgUrl($url);
             $captchaImage->setImgDir($captchaPath);
             $captcha = new Element\Captcha('isHuman');
             $captcha->setCaptcha($captchaImage)->setAttributes(array('class' => 'form-control'));
             $form->add($captcha);
         }
         $form->setAttribute('class', 'form-horizontal');
         $form->add($txtUser);
         $form->add($password);
         $form->add($remember);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:27,代码来源:AuthHelper.php

示例4: __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);
 }
开发者ID:PoetikDragon,项目名称:USCSS,代码行数:35,代码来源:Login.php

示例5: 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

示例6: addCSRFElement

 public function addCSRFElement($name, $value)
 {
     $csrf = new \Zend\Form\Element\Hidden($name);
     $csrf->setValue($value);
     $this->form->add($csrf);
     return $this;
 }
开发者ID:caseypage,项目名称:php-ssrs-1,代码行数:7,代码来源:ZendFramework2.php

示例7: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form('create_cv');
     //$form->add($serviceLocator->get('ApplicationFieldset'));
     $form->add($serviceLocator->get('EducationCollection'));
     $form->add($serviceLocator->get('DefaultButtonsFieldset'), array('name' => 'buttons'));
     return $form;
 }
开发者ID:bitrecruiter,项目名称:CrossApplicantManager,代码行数:8,代码来源:CvFactory.php

示例8: createService

 /**
  * @inheritdoc
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form();
     $form->add(new Element\Text('filter', ['label' => 'Resource']));
     $form->add(new Element\Button('submit', ['label' => 'filter']));
     $form->setAttribute('method', 'GET');
     $form->get('submit')->setAttribute('type', 'submit');
     return $form;
 }
开发者ID:enlitepro,项目名称:enlite-admin,代码行数:12,代码来源:ACLFilterFormFactory.php

示例9: 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

示例10: 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

示例11: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     //        $config = $serviceLocator->get('config_authentification_form');
     //        $factory = new Factory();
     //        $form = $factory->createForm( $config );
     $form = new Form();
     $form->add(new \MiniModule\Form\Element\Login());
     $form->add(new \MiniModule\Form\Element\Password());
     $form->add(new Submit('submit'));
     return $form;
 }
开发者ID:benjyspider,项目名称:ZF,代码行数:11,代码来源:AuthentificationFormFactory.php

示例12: getForm

 public function getForm(array $default_status)
 {
     if (!$this->form) {
         $hidId = new Element\Hidden();
         $hidId->setName('userId');
         $txtName = new Element\Text();
         $txtName->setLabel('User Name')->setName("userName")->setAttribute('class', 'form-control');
         $password = new Element\Password();
         $password->setLabel('Password')->setName('password')->setAttribute('class', 'form-control');
         $confirmPassword = new Element\Password();
         $confirmPassword->setName('confirmPassword')->setLabel('Retype Password')->setAttribute('class', 'form-control');
         $selectRole = new Element\Hidden('userRole');
         $description = new Element\Textarea();
         $description->setName('description')->setLabel('Description')->setAttribute('class', 'form-control');
         $status = new Element\Select();
         $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($default_status);
         $image = new Element\File();
         $image->setName('image')->setLabel('Profile image');
         $form = new Form();
         $form->setAttribute('class', 'form-horizontal');
         $form->setAttribute('enctype', 'multipart/form-data');
         $form->add($hidId);
         $form->add($txtName);
         $form->add($password);
         $form->add($confirmPassword);
         $form->add($selectRole);
         $form->add($description);
         $form->add($status);
         $form->add($image);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:33,代码来源:UserHelper.php

示例13: getLeaveForm

 public function getLeaveForm(array $leaveList)
 {
     $leaveType = new Element\Select();
     $leaveType->setName('leaveType')->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($leaveList);
     $date = new Element\Date();
     $date->setName('date')->setLabel('Date')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
     $description = new Element\Textarea('description');
     $description->setLabel('Description')->setAttribute('class', 'form-control');
     $form = new Form();
     $form->setAttribute('class', 'form');
     $form->add($leaveType);
     $form->add($date);
     $form->add($description);
     return $form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:15,代码来源:DashboardHelper.php

示例14: testRender

 public function testRender()
 {
     $form = new Form();
     $attributes = array('name' => 'login-form');
     $form->setAttributes($attributes);
     $form->add(new CityFieldset());
     $form->add(new Submit('send'));
     $markup = $this->helper->__invoke($form);
     $this->assertContains('<form', $markup);
     $this->assertContains('id="login-form"', $markup);
     $this->assertContains('<label><span>Name of the city</span>', $markup);
     $this->assertContains('<fieldset><legend>Country</legend>', $markup);
     $this->assertContains('<input type="submit" name="send"', $markup);
     $this->assertContains('</form>', $markup);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:15,代码来源:FormTest.php

示例15: testCorrectInputDataMerging

 public function testCorrectInputDataMerging()
 {
     $this->disablePhpUploadCapabilities();
     $form = new Form();
     $form->add(['name' => 'collection', 'type' => 'collection', 'options' => ['target_element' => new TestAsset\TestFieldset('target'), 'count' => 2]]);
     copy(__DIR__ . '/TestAsset/nullfile', __DIR__ . '/TestAsset/nullfile_copy');
     $request = $this->request;
     $request->setMethod('POST');
     $request->setPost(new Parameters(['collection' => [0 => ['text' => 'testvalue1'], 1 => ['text' => '']]]));
     $request->setFiles(new Parameters(['collection' => [0 => ['file' => ['name' => 'test.jpg', 'type' => 'image/jpeg', 'size' => 20480, 'tmp_name' => __DIR__ . '/TestAsset/nullfile_copy', 'error' => UPLOAD_ERR_OK]]]]));
     $this->controller->dispatch($this->request, $this->response);
     $plugin = $this->plugin;
     $plugin($form, '/test/getPage', true);
     $this->assertFalse($form->isValid());
     $data = $form->getData();
     // @codingStandardsIgnoreStart
     $this->assertEquals(['collection' => [0 => ['text' => 'testvalue1', 'file' => ['name' => 'test.jpg', 'type' => 'image/jpeg', 'size' => 20480, 'tmp_name' => __DIR__ . DIRECTORY_SEPARATOR . 'TestAsset' . DIRECTORY_SEPARATOR . 'testfile.jpg', 'error' => 0]], 1 => ['text' => null, 'file' => null]]], $data);
     // @codingStandardsIgnoreEnd
     $this->assertFileExists($data['collection'][0]['file']['tmp_name']);
     unlink($data['collection'][0]['file']['tmp_name']);
     $messages = $form->getMessages();
     $this->assertTrue(isset($messages['collection'][1]['text'][NotEmpty::IS_EMPTY]));
     $requiredFound = false;
     foreach ($messages['collection'][1]['file'] as $message) {
         if (strpos($message, 'Value is required') === 0) {
             $requiredFound = true;
             break;
         }
     }
     $this->assertTrue($requiredFound, '"Required" message was not found in validation failure messages');
 }
开发者ID:zendframework,项目名称:zend-mvc-plugin-fileprg,代码行数:31,代码来源:FilePrgDataMergingTest.php


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