當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::bindValues方法代碼示例

本文整理匯總了PHP中Zend\Form\Form::bindValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::bindValues方法的具體用法?PHP Form::bindValues怎麽用?PHP Form::bindValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\Form的用法示例。


在下文中一共展示了Form::bindValues方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testPrepareBindDataAllowsFilterToConvertStringToArray

 public function testPrepareBindDataAllowsFilterToConvertStringToArray()
 {
     $data = array('foo' => '1,2');
     $filteredData = array('foo' => array(1, 2));
     $element = new TestAsset\ElementWithStringToArrayFilter('foo');
     $hydrator = $this->getMock('Zend\\Stdlib\\Hydrator\\ArraySerializable');
     $hydrator->expects($this->any())->method('hydrate')->with($filteredData, $this->anything());
     $this->form->add($element);
     $this->form->setHydrator($hydrator);
     $this->form->setObject(new stdClass());
     $this->form->setData($data);
     $this->form->bindValues($data);
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:13,代碼來源:FormTest.php

示例2: testCallingBindValuesWhenBindOnValidateIsDisabledPopulatesBoundObject

 public function testCallingBindValuesWhenBindOnValidateIsDisabledPopulatesBoundObject()
 {
     $model = new stdClass();
     $validSet = array('foo' => 'abcde', 'bar' => ' ALWAYS valid ', 'foobar' => array('foo' => 'abcde', 'bar' => ' always VALID'));
     $this->populateForm();
     $this->form->setHydrator(new Hydrator\ObjectProperty());
     $this->form->setBindOnValidate(false);
     $this->form->bind($model);
     $this->form->setData($validSet);
     $this->form->isValid();
     $this->assertObjectNotHasAttribute('foo', $model);
     $this->assertObjectNotHasAttribute('bar', $model);
     $this->assertObjectNotHasAttribute('foobar', $model);
     $this->form->bindValues();
     $this->assertObjectHasAttribute('foo', $model);
     $this->assertEquals($validSet['foo'], $model->foo);
     $this->assertObjectHasAttribute('bar', $model);
     $this->assertEquals('always valid', $model->bar);
     $this->assertObjectHasAttribute('foobar', $model);
     $this->assertEquals(array('foo' => 'abcde', 'bar' => 'always valid'), $model->foobar);
 }
開發者ID:rcastardo,項目名稱:zf2,代碼行數:21,代碼來源:FormTest.php

示例3: processForm

 protected function processForm(Form $form, $options = array(), $extra1 = null, $extra2 = array())
 {
     /**
      * Special case for a simpler API: if the second argument is a string, it is used as the route to redirect
      * to, the third argument as the route parameters and the fourth argument as additional options.
      */
     if (is_string($options)) {
         $options = array('redirect_route' => $options, 'redirect_params' => $extra1);
         $options = $options + $extra2;
     }
     if ($options && isset($options['object_manager'])) {
         $objectManager = $options['object_manager'];
     } else {
         $objectManager = $this->getEntityManager();
     }
     /** @var $request Request */
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $form->bindValues();
             $objectManager->persist($form->getObject());
             $objectManager->flush();
             if (!empty($options['success_message'])) {
                 $this->flashMessenger()->addMessage($options['success_message']);
             }
             if (!empty($options['redirect_route'])) {
                 $params = array();
                 if (!empty($options['redirect_params'])) {
                     $params = $options['redirect_params'];
                     if (is_callable($params)) {
                         $params = call_user_func($params, $form);
                     }
                 }
                 return $this->redirect()->toRoute($options['redirect_route'], $params);
             }
         }
     }
     return null;
 }
開發者ID:rieschl,項目名稱:admin-module,代碼行數:40,代碼來源:AbstractAdminController.php

示例4: getFormObject

 /**
  * Возвращает объект привязанный к форме
  *
  * @param Form $form
  *
  * @return mixed
  * @throws \Assert\AssertionFailedException
  */
 protected function getFormObject(Form $form)
 {
     $form->bindValues();
     $object = $form->getObject();
     Assertion::isInstanceOf($object, GitLabDto::class);
     return $object;
 }
開發者ID:old-town-gitlab-tools,項目名稱:core,代碼行數:15,代碼來源:UpdateController.php


注:本文中的Zend\Form\Form::bindValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。