本文整理汇总了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();
}
示例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();
}
}
示例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);
}
示例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>