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


PHP Form::get方法代码示例

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


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

示例1: getFilter

 /**
  * @param null $name
  * @return \Zend\Form\ElementInterface|Form
  */
 public function getFilter($name = null)
 {
     if (!empty($name)) {
         return $this->filter->get($name);
     }
     return $this->filter;
 }
开发者ID:sebaks,项目名称:Translate,代码行数:11,代码来源:ListViewModel.php

示例2: __invoke

 public function __invoke(Form $form)
 {
     $form->setAttribute('class', self::DEFAULT_FORM_CLASS);
     foreach ($form->getElements() as $element) {
         /*
          * controls how far the form indents into
          * the page using Twitter:Bootstrap CSS
          *
          */
         $defLabelAttributes = array('class' => self::DEFAULT_LABEL_CLASS);
         $element->setLabelAttributes($defLabelAttributes);
         $element->setAttribute('class', self::DEFAULT_INPUT_CLASS);
         /*
          * set the id attribute of all inputs to be equal to their names
          *
          * makes life simple when trying to make the view
          * dynamic
          */
         $element->setAttribute('id', $element->getName());
     }
     /*
      * the submit button is a little different, it uses
      * a button class to proper rendering
      *
      */
     $form->get('submit')->setAttribute('class', self::DEFAULT_SUBMIT_BUTTON_CLASS);
     return $form;
 }
开发者ID:decmade,项目名称:zendAbacAcl,代码行数:28,代码来源:AddBootstrapFormAttributes.php

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

示例4: __invoke

 public function __invoke($keyData, $keyEndPoint, array $data, Form $form)
 {
     $html = '';
     $options = array_key_exists('options', $data) ? $data['options'] : array();
     $form->get('endpoint')->setValue($keyEndPoint);
     $html .= $this->getView()->partial('helpers/partials/default-process-control', array('keyData' => $keyData, 'keyEndPoint' => $keyEndPoint, 'label' => $data['label'], 'processDescription' => array_key_exists('process-description', $data) ? $data['process-description'] : '', 'form' => $form, 'class' => 'DefaultProcessControl', 'options' => $options));
     return $html;
 }
开发者ID:dsi-agpt,项目名称:minibus,代码行数:8,代码来源:DefaultProcessControlHelper.php

示例5: testResetPasswordValueIfFormIsNotValid

 public function testResetPasswordValueIfFormIsNotValid()
 {
     $this->form->add(array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'password'));
     $this->form->add(array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'email'));
     $this->form->setData(array('password' => 'azerty', 'email' => 'wrongEmail'));
     $this->assertFalse($this->form->isValid());
     $this->form->prepare();
     $this->assertEquals('', $this->form->get('password')->getValue());
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:9,代码来源:FormTest.php

示例6: fixUserForm

 /**
  * @param \Zend\Form\Form $form
  */
 protected function fixUserForm(Form &$form, $userId = null)
 {
     $auth = $this->getAuthenticationService();
     $groupId = $form->get('groupId');
     $groups = $groupId->getValueOptions();
     if (empty($groups) || $auth->getIdentity()->id == $userId) {
         $form->remove('groupId');
     }
 }
开发者ID:gridguyz,项目名称:core,代码行数:12,代码来源:AdminController.php

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

示例8: __invoke

 /**
  * @param Form $form
  * @param array $fields
  * @param array $overwrite
  *
  * @return string
  */
 public function __invoke($form, $fields, $overwrite = null)
 {
     if ($overwrite === null) {
         $overwrite = array();
     }
     if (!is_array($fields)) {
         $fields = array($fields);
     }
     $html = '';
     foreach ($fields as $i => $field) {
         $addon = '';
         if (!is_int($i)) {
             $addon = $field;
             $field = $i;
         }
         if (!$form->has($field)) {
             throw new \Exception(sprintf('Element doesn\'t exists \'%s\'', $field));
         }
         $element = $form->get($field);
         $type = strtolower($element->getAttribute('type'));
         if (array_key_exists($field, $overwrite)) {
             if ($type === 'submit') {
                 $element->setValue($overwrite[$field]);
             } else {
                 $element->setOption('label', $overwrite[$field]);
             }
         }
         $plugin = $this->getPlugin($type);
         $prefix = '';
         $encaps = '%s';
         switch ($type) {
             case 'checkbox':
                 $encaps = sprintf("<div class=\"checkbox-block\">%s</div><div class=\"col-xs-10\">%s</div>", '%s', $this->getLabel($element));
                 break;
             case "textarea":
                 if (preg_match('/readonly/i', $element->getAttribute('class'))) {
                     $prefix = '<p class="toggle-edit"><a href="#">Edit</a></p><iframe style="width:200px; height:100px; display: none;"></iframe>';
                 }
             default:
                 $prefix .= $this->getLabel($element);
                 break;
         }
         $input = $plugin($element);
         if (!empty($prefix)) {
             $prefix = sprintf($this->labelBlock, $prefix);
         }
         $html .= sprintf($this->format, $element->getName(), $prefix, sprintf($encaps, $input), $addon, $this->buildErrorMessage($element));
     }
     return $html;
 }
开发者ID:elmosgot,项目名称:cool-builder,代码行数:57,代码来源:RenderElements.php

示例9: testElementInAFieldsetForSomeModel

 public function testElementInAFieldsetForSomeModel()
 {
     $element = $this->getMoneyFieldset();
     $element->init();
     $fieldset = new Fieldset('hasMoneyElementFieldset');
     $fieldset->add($element, ['name' => 'price']);
     $fieldset->setHydrator(new ClassMethods());
     $fieldset->setUseAsBaseFieldset(true);
     $form = new Form();
     $form->add($fieldset);
     // todo: can't load this
     $form->bind(new HasMoneyPropertyModel());
     $data = ['hasMoneyElementFieldset' => ['price' => ['amount' => '500.25', 'currency' => 'BRL']]];
     $form->setData($data);
     $this->assertTrue($form->isValid());
     $amountValue = $form->get('hasMoneyElementFieldset')->get('price')->get('amount')->getValue();
     $currencyValue = $form->get('hasMoneyElementFieldset')->get('price')->get('currency')->getValue();
     $object = $form->getData();
     $this->assertSame('500.25', $amountValue);
     $this->assertSame('BRL', $currencyValue);
     $this->assertInstanceOf(Money::class, $object->getPrice());
     $this->assertSame(50025, $object->getPrice()->getAmount());
     $this->assertSame('BRL', $object->getPrice()->getCurrency()->getName());
 }
开发者ID:zfbrasil,项目名称:doctrine-money-module,代码行数:24,代码来源:FormIntegrationTest.php

示例10: formErros

 /**
  * Pega as mensagens do formulario e as dispoe
  * em forma de lista ul,li
  * @param \Zend\Form\Form $form
  * @return string HTML
  */
 public function formErros($form)
 {
     $msg = "";
     $arrayMessage = $form->getMessages();
     foreach ($arrayMessage as $elemName => $messages) {
         foreach ($messages as $message) {
             $label = "";
             $elemName = $form->get($elemName);
             if ($elemName != null) {
                 $label = $elemName->getLabel();
             }
             $msg .= "<ul><li>" . $label . " " . $message . "</li></ul>";
         }
     }
     return $msg;
 }
开发者ID:argentinaluiz,项目名称:js_zf2_library,代码行数:22,代码来源:Format.php

示例11: get

 /**
  * {@inheritDoc}
  */
 public function get($elementOrFieldset)
 {
     if (!parent::has($elementOrFieldset)) {
         if ($elementOrFieldset === 'captcha') {
             $elementOrFieldset = $this->getCaptchaElementName();
         } elseif ($elementOrFieldset === 'csrf') {
             $elementOrFieldset = $this->getCsrfElementName();
         }
     }
     return parent::get($elementOrFieldset);
 }
开发者ID:coolms,项目名称:common,代码行数:14,代码来源:Form.php

示例12: testSubFieldsetsBindObject

 public function testSubFieldsetsBindObject()
 {
     $form = new Form();
     $fieldset = new Fieldset('foobar');
     $form->add($fieldset);
     $value = new \ArrayObject(array('foobar' => 'abc'));
     $value['foobar'] = new \ArrayObject(array('foo' => 'abc'));
     $form->bind($value);
     $this->assertSame($fieldset, $form->get('foobar'));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:10,代码来源:FieldsetTest.php

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

示例14: fillData

 /**
  * @param Form $form
  * @param int $moneyAccountId
  * @return Form
  */
 public function fillData($form, $moneyAccountId)
 {
     /** @var UserManager $userDao */
     $userDao = new UserManager($this->getServiceLocator(), '\\ArrayObject');
     if ($moneyAccountId) {
         $users = $this->getMoneyAccountUsersInOperationTypes($moneyAccountId);
         $usersForView = $form->get('view_transactions')->getOption('value_options');
         if (isset($users[self::OPERATION_VIEW_TRANSACTION]) && count($users[self::OPERATION_VIEW_TRANSACTION])) {
             foreach ($users[self::OPERATION_VIEW_TRANSACTION] as $relUserId) {
                 if (!isset($usersForView[$relUserId])) {
                     $userDomain = $userDao->getUserById($relUserId, true);
                     $usersForView[$relUserId] = $userDomain['firstname'] . ' ' . $userDomain['lastname'];
                     $form->get('view_transactions')->setOptions(['value_options' => $usersForView]);
                 }
             }
         }
         $usersForAdd = $form->get('add_transactions')->getOption('value_options');
         if (isset($users[self::OPERATION_ADD_TRANSACTION]) && count($users[self::OPERATION_ADD_TRANSACTION])) {
             foreach ($users[self::OPERATION_ADD_TRANSACTION] as $relUserId) {
                 if (!isset($usersForAdd[$relUserId])) {
                     $userDomain = $userDao->getUserById($relUserId, true);
                     $usersForAdd[$relUserId] = $userDomain['firstname'] . ' ' . $userDomain['lastname'];
                     $form->get('add_transactions')->setOptions(['value_options' => $usersForAdd]);
                 }
             }
         }
         $transactionManagers = $form->get('manage_transactions')->getOption('value_options');
         if (isset($users[self::OPERATION_MANAGE_TRANSACTION]) && count($users[self::OPERATION_MANAGE_TRANSACTION])) {
             foreach ($users[self::OPERATION_MANAGE_TRANSACTION] as $relUserId) {
                 if (!isset($transactionManagers[$relUserId])) {
                     $userDomain = $userDao->getUserById($relUserId, true);
                     $transactionManagers[$relUserId] = $userDomain['firstname'] . ' ' . $userDomain['lastname'];
                     $form->get('manage_transactions')->setOptions(['value_options' => $transactionManagers]);
                 }
             }
         }
         $accountManagers = $form->get('manage_transactions')->getOption('value_options');
         if (isset($users[self::OPERATION_MANAGE_ACCOUNT]) && count($users[self::OPERATION_MANAGE_ACCOUNT])) {
             foreach ($users[self::OPERATION_MANAGE_ACCOUNT] as $relUserId) {
                 if (!isset($accountManagers[$relUserId])) {
                     $userDomain = $userDao->getUserById($relUserId, true);
                     $accountManagers[$relUserId] = $userDomain['firstname'] . ' ' . $userDomain['lastname'];
                     $form->get('manage_transactions')->setOptions(['value_options' => $accountManagers]);
                 }
             }
         }
         $form->setData(['view_transactions' => isset($users[self::OPERATION_VIEW_TRANSACTION]) ? $users[self::OPERATION_VIEW_TRANSACTION] : [], 'add_transactions' => isset($users[self::OPERATION_ADD_TRANSACTION]) ? $users[self::OPERATION_ADD_TRANSACTION] : [], 'manage_transactions' => isset($users[self::OPERATION_MANAGE_TRANSACTION]) ? $users[self::OPERATION_MANAGE_TRANSACTION] : [], 'manage_account' => isset($users[self::OPERATION_MANAGE_ACCOUNT]) ? $users[self::OPERATION_MANAGE_ACCOUNT] : []]);
     }
     return $form;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:55,代码来源:MoneyAccount.php

示例15: populateForm

 /**
  * Fill form with the data
  *
  * @param \Zend\Form\Form $form
  * @param $entity
  */
 protected function populateForm($form, $entity)
 {
     //
     $form->get('id')->setValue($entity->getId());
 }
开发者ID:msingi,项目名称:msingi,代码行数:11,代码来源:AbstractEntitiesController.php


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