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


PHP sfForm::getEmbeddedForm方法代码示例

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


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

示例1: doPreSave

 protected function doPreSave(Doctrine_Record $record, sfForm $form)
 {
     // loop through relations
     if ($relations = $form->getOption('dynamic_relations')) {
         foreach ($relations as $field => $config) {
             $collection = $record->get($config['relation']->getAlias());
             // collect form objects for comparison
             $search = array();
             foreach ($form->getEmbeddedForm($field)->getEmbeddedForms() as $i => $embed) {
                 $search[] = $embed->getObject();
             }
             foreach ($collection as $i => $object) {
                 if (false === ($pos = array_search($object, $search, true))) {
                     // if a related object exists in the record but isn't represented
                     // in the form, the reference has been removed
                     $collection->remove($i);
                     // if the foreign column is a notnull columns, delete the object
                     $column = $config['relation']->getTable()->getColumnDefinition($config['relation']->getForeignColumnName());
                     if ($object->exists() && isset($column['notnull']) && $column['notnull']) {
                         $object->delete();
                     }
                 }
             }
         }
     }
 }
开发者ID:rschumacher,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:26,代码来源:sfDoctrineDynamicFormRelationsListener.class.php

示例2: doPreSave

 protected function doPreSave(Doctrine_Record $record, sfForm $form)
 {
     // loop through relations
     if ($relations = $form->getOption('dynamic_relations')) {
         foreach ($relations as $field => $config) {
             $collection = $record->get($config['relation']->getAlias());
             // collect form objects for comparison
             $search = array();
             try {
                 foreach ($form->getEmbeddedForm($field)->getEmbeddedForms() as $i => $embed) {
                     $search[] = $embed->getObject();
                 }
             } catch (InvalidArgumentException $e) {
                 // previously embedded form was removed at the end of form.filter_values as there were no values for it.
                 // @see sfDoctrineDynamicFormRelations::correctValidators()
             }
             foreach ($collection as $i => $object) {
                 $pos = array_search($object, $search, true);
                 if (false === $pos && $this->filterObject($object, $config['arguments'])) {
                     // if a related object exists in the record but isn't represented
                     // in the form, the reference has been removed
                     $collection->remove($i);
                     // if the foreign column is a notnull columns, delete the object
                     $column = $config['relation']->getTable()->getColumnDefinition($config['relation']->getForeignColumnName());
                     if ($object->exists() && isset($column['notnull']) && $column['notnull']) {
                         $object->delete();
                     }
                 }
             }
         }
     }
 }
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:32,代码来源:sfDoctrineDynamicFormRelationsListener.class.php

示例3: findEmbeddedFormById

 /**
  * Finds a form embedded in the supplied form based on id.
  *
  * @param sfForm $form  A form
  * @param string $field The field name used for embedding
  * @param mixed  $id    An id value
  *
  * @return sfForm|null The embedded form, if one is found
  */
 protected function findEmbeddedFormById(sfForm $form, $field, $id)
 {
     foreach ($form->getEmbeddedForm($field)->getEmbeddedForms() as $embed) {
         if ($id == $embed->getObject()->get('id')) {
             return $embed;
         }
     }
 }
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:17,代码来源:sfDoctrineDynamicFormRelations.class.php

示例4: processForm

 /**
  *
  * @param sfWebRequest $request
  * @param sfForm $form
  */
 private function processForm(sfWebRequest $request, sfForm $form, $account_id = null)
 {
     $parameters = $request->getParameter($form->getName());
     if ($parameters['imputation']['imputation_type'] == ImputationDefaultValues::COUNTABLE_SERVICE_TYPE) {
         $parameters['account']['value'] = $parameters['initial_value'];
         $parameters['account']['monetary_account'] = $form->getObject()->getImputation()->getAct()->getMonetaryAccount();
         $parameters['account']['created_at'] = $parameters['imputation']['date'];
         $parameters['account']['act_id'] = $form->getObject()->getImputation()->getActId();
         unset($parameters['account_is_shared']);
     }
     $form->bind($parameters);
     if ($form->isValid()) {
         //If the method of payment is 'account':
         if ($parameters['imputation']['method_of_payment_id'] == ImputationDefaultValues::getAccountMethodId()) {
             //We create a new 'hidden' imputation of type account_transaction
             if (ImputationAccountTransaction::buildAndSaveTransactionFrom($parameters)) {
                 $saved_object = $form->save();
                 $this->error_account = false;
             } else {
                 if ($parameters['imputation']['account_id'] == 0) {
                     $this->error_account = true;
                 } else {
                     $this->error_account = false;
                 }
                 return false;
             }
         } else {
             $saved_object = $form->save();
             $this->error_account = false;
         }
         //If the type of the imputation is 'countable_service'
         if ($parameters['imputation']['imputation_type'] == ImputationDefaultValues::COUNTABLE_SERVICE_TYPE) {
             //We create a new account user entry:
             if (!is_null($account_id)) {
                 ImputationCountableService::createAccountUser($form->getEmbeddedForm('imputation')->getObject()->getUserId(), $account_id);
             } else {
                 $this->current_account_id = ImputationCountableService::createAccountUser($form->getEmbeddedForm('imputation')->getObject()->getUserId(), $form->getEmbeddedForm('account')->getObject()->getId());
             }
         }
         //A FAIRE ICI: DUPLICATION DANS LA TABLE ARCHIVE
         /**
          * @todo
          */
         $archive = new ImputationArchive();
         $archive->fillAndSave($form);
         return true;
     } else {
         if ($parameters['imputation']['account_id'] == 0) {
             $this->error_account = true;
         } else {
             $this->error_account = false;
         }
         return false;
     }
 }
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:60,代码来源:actions.class.php

示例5: processForm

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $this->getResponse()->setContentType('application/json');
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $isNew = $this->ei_block->isNew();
         $this->ei_block = $form->save();
         if ($isNew && !$this->isFull) {
             if ($this->insert_after) {
                 $this->ei_block->getNode()->insertAsNextSiblingOf($this->ei_block_parent);
             } else {
                 $this->ei_block->getNode()->insertAsFirstChildOf($this->ei_block_parent);
             }
         } elseif ($isNew && $this->isFull && $this->ei_vs_precedent != null) {
             $this->ei_block->getNode()->insertAsNextSiblingOf($this->ei_vs_precedent);
         } elseif ($isNew && $this->isFull && $this->ei_block_parent != null && $this->ei_vs_precedent == null) {
             $this->ei_block->getNode()->insertAsFirstChildOf($this->ei_block_parent);
         }
         if ($isNew && $this->isFull && array_key_exists("EiBlockParams", $form->getEmbeddedForms()) && !$this->ei_block->isEiLoop()) {
             $forms = $form->getEmbeddedForm("EiBlockParams")->getEmbeddedForms();
             $prev = null;
             /** @var EiBlockParamForm $form */
             foreach ($forms as $form) {
                 if ($prev == null) {
                     $form->getObject()->getNode()->insertAsLastChildOf($this->ei_block);
                 } else {
                     $form->getObject()->getNode()->insertAsNextSiblingOf($prev);
                 }
                 $prev = $form->getObject();
             }
         } elseif ($isNew && $this->isFull && $this->ei_block->isEiLoop()) {
             $this->ei_block->createAutoMapping();
         } elseif (!$isNew && $this->isFull && array_key_exists("EiBlockParams", $form->getEmbeddedForms())) {
             $forms = $form->getEmbeddedForm("EiBlockParams")->getEmbeddedForms();
             $prev = null;
             $nouvelleCollection = array();
             /** @var EiBlockParamForm $form */
             foreach ($forms as $form) {
                 $nouvelleCollection[] = $form->getObject()->getId();
                 if ($prev == null && $form->getObject()->getLft() == null) {
                     $form->getObject()->getNode()->insertAsLastChildOf($this->ei_block);
                 } elseif ($form->getObject()->getLft() == null) {
                     $form->getObject()->getNode()->insertAsNextSiblingOf($prev);
                 }
                 $prev = $form->getObject();
             }
             foreach ($this->ei_block->getEiVersionStructures() as $key => $structureElt) {
                 if ($structureElt instanceof EiBlockParam && !in_array($structureElt->getId(), $nouvelleCollection)) {
                     $this->ei_block->getEiVersionStructures()->remove($key);
                 }
             }
             $this->ei_block->save();
         }
         return false;
     } else {
         $JSONResponse['status'] = "error";
         $errors = $form->getErrorSchema()->getErrors();
         if (isset($errors["name"])) {
             $nomErreur = $errors["name"];
         } else {
             $nomErreur = "";
         }
         $JSONResponse['message'] = "Unable to save the block. " . $nomErreur;
     }
     return $JSONResponse;
 }
开发者ID:lendji4000,项目名称:compose,代码行数:66,代码来源:actions.class.php

示例6: processForm

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->save();
         $form_pass = $form->getEmbeddedForm('MdP');
         $form_pass->bind($form->getValue('MdP'));
         $form_pass->save();
         $this->getUser()->setFlash('notice', 'Mise à jour du profil effectuée.');
         $this->redirect('etudiant/edit');
     }
 }
开发者ID:googlecode-mirror,项目名称:copisim,代码行数:12,代码来源:actions.class.php


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