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


PHP BaseForm::getWidgetSchema方法代码示例

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


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

示例1: setup

 /**
  * Overridden to allow the app to add to the form and then to process
  * those additions and turn them into one giant, embedded form
  */
 public function setup()
 {
     // allow the application to add fields to the form
     self::$dispatcher->notify(new sfEvent($this, 'sympal.load_config_form'));
     $otherSettings = array();
     foreach ($this->_settings as $group => $settings) {
         if (!is_numeric($group)) {
             $form = new BaseForm();
             foreach ($settings as $setting) {
                 $form->setWidget($setting['name'], $setting['widget']);
                 $form->getWidgetSchema()->setLabel($setting['name'], $setting['label']);
                 $form->setValidator($setting['name'], $setting['validator']);
             }
             $this->embedForm($group, $form);
         } else {
             $otherSettings[] = $settings;
         }
     }
     foreach ($otherSettings as $setting) {
         $this->setWidget($setting['name'], $setting['widget']);
         $this->getWidgetSchema()->setLabel($setting['name'], $setting['label']);
         $this->setValidator($setting['name'], $setting['validator']);
     }
     $defaults = $this->getDefaults();
     foreach ($this as $key => $value) {
         if ($value instanceof sfFormFieldSchema) {
             foreach ($value as $k => $v) {
                 $defaults[$key][$k] = sfSympalConfig::get($key, $k);
             }
         } else {
             $defaults[$key] = sfSympalConfig::get($key);
         }
     }
     $this->setDefaults($defaults);
     $this->widgetSchema->setNameFormat('settings[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
开发者ID:sympal,项目名称:sympal,代码行数:42,代码来源:sfSympalConfigForm.class.php

示例2: executeDeletePair

 public function executeDeletePair(sfWebRequest $request)
 {
     $pair = MappingPairTable::getInstance()->find($request->getParameter('id'));
     if (!$pair) {
         return $this->notFound();
     }
     /* @var $pair MappingPair */
     $form = new BaseForm();
     $form->getWidgetSchema()->setNameFormat('delete_pair[%s]');
     $form->bind($request->getPostParameter($form->getName()));
     if ($form->isValid()) {
         $id = $pair->getId();
         $pair->delete();
         return $this->ajax()->remove('#pair_' . $id)->remove('#pair_form_' . $id)->render();
     } else {
         return $this->ajax()->form($form)->render();
     }
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:18,代码来源:actions.class.php

示例3: embedRelationAndCreate

 /**
  * Embed a Doctrine_Collection relationship in to a form
  *
  *     [php]
  *     $userForm = new UserForm($user);
  *     $userForm->embedRelationAndCreate('Groups');
  *
  * @param  string $relationName  The name of the relation
  * @param  string $formClass     The name of the form class to use
  * @param  array  $formArguments Arguments to pass to the constructor (related object will be shifted onto the front)
  *
  * @throws InvalidArgumentException If the relationship is not a collection
  */
 public function embedRelationAndCreate($relationName, $parentForm = null, $formClass = null, $formArgs = array(), $formatter = 'table')
 {
     if ($this->isNew()) {
         return;
     }
     if ($parentForm == null) {
         $parentForm = $this;
     }
     $this->_relations[] = $relationName;
     $relation = $this->getObject()->getTable()->getRelation($relationName);
     if ($relation->getType() !== Doctrine_Relation::MANY) {
         throw new InvalidArgumentException('You can only embed a relationship that is a collection.');
     }
     $r = new ReflectionClass(null === $formClass ? $relation->getClass() . 'Form' : $formClass);
     $subForm = new BaseForm();
     $relations = $parentForm->getObject()->getTable()->getRelations();
     $relationColumn = $relations[$relationName]['foreign'];
     foreach ($this->getObject()->{$relationName} as $index => $childObject) {
         $r = new ReflectionClass(null === $formClass ? get_class($childObject) . 'Form' : $formClass);
         $form = $r->newInstanceArgs(array_merge(array($childObject), $formArgs));
         unset($form[$relationColumn]);
         $form->setWidget('delete', new sfWidgetFormInputCheckbox());
         $subForm->embedForm($index, $form);
         $subForm->getWidgetSchema()->setLabel($index, (string) $childObject);
         $subForm->getWidgetSchema()->setFormFormatterName($formatter);
     }
     $object = $relation->getClass();
     $childObject = new $object();
     $childObject->{$relationColumn} = $parentForm->getObject()->id;
     $r = new ReflectionClass(null === $formClass ? $relation->getClass() . 'Form' : $formClass);
     $form = $r->newInstanceArgs(array_merge(array($childObject), $formArgs));
     $form->setWidget('create', new sfWidgetFormInputCheckbox());
     $form->setValidator('create', new sfValidatorPass());
     //$form->isNew(true);
     unset($form[$relationColumn]);
     $subForm->getWidgetSchema()->setFormFormatterName($formatter);
     $subForm->embedForm('new', $form);
     $this->embedForm($relationName, $subForm);
 }
开发者ID:servs,项目名称:nFormEmbedPlugin,代码行数:52,代码来源:nBaseEmbedForm.class.php

示例4: url_for

<?php

/* @var $pair MappingPair */
$form = new BaseForm();
$form->getWidgetSchema()->setNameFormat('delete_pair[%s]');
?>
<tr id="pair_<?php 
echo $pair['id'];
?>
">
  <td><?php 
echo $pair['a'];
?>
</td>
  <td><?php 
echo $pair['b'];
?>
</td>
  <td>
    <form class="ajax_form" method="post" action="<?php 
echo url_for('mapping_delete_pair', array('id' => $pair['id']));
?>
"><?php 
echo $form;
?>
      <a class="btn btn-mini ajax_link" href="<?php 
echo url_for('mapping_edit_pair', array('id' => $pair['id']));
?>
">edit</a>
      <button class="btn btn-mini  btn-warning">delete</button>
    </form>
开发者ID:uniteddiversity,项目名称:policat,代码行数:31,代码来源:_pair_row.php


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