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


PHP sfForm::getEmbeddedForms方法代码示例

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


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

示例1: correctValidators

 /**
  * Replacing validators with their up-to-date equivalent from an embedded form.
  *
  * @param  sfForm $form Form instance on which to replace validators
  *
  * @return sfValidatorSchema
  */
 protected function correctValidators($form)
 {
     foreach ($form->getEmbeddedForms() as $field => $embed) {
         if ($form->getValidator($field) instanceof sfValidatorSchema) {
             foreach ($embed->getValidatorSchema()->getFields() as $name => $validator) {
                 if (!$form->getValidator($field)->offsetExists($name)) {
                     $embed->getValidatorSchema()->offsetUnset($name);
                 }
             }
             $form->setValidator($field, $this->correctValidators($embed));
         }
     }
     return $form->getValidatorSchema();
 }
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:21,代码来源:sfDoctrineDynamicFormRelations.class.php

示例2: mergeForm

 /**
  * Overrides sfForm::mergeForm() to also merge embedded forms
  * Allows autosave of merged collections
  *
  * @param  sfForm   $form      The sfForm instance to merge with current form
  *
  * @throws LogicException      If one of the form has already been bound
  */
 public function mergeForm(sfForm $form)
 {
     foreach ($form->getEmbeddedForms() as $name => $embeddedForm) {
         $this->embedForm($name, clone $embeddedForm);
     }
     parent::mergeForm($form);
 }
开发者ID:sanemat,项目名称:bllik,代码行数:15,代码来源:sfFormPropel.class.php

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


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