本文整理汇总了PHP中sfForm::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::setOption方法的具体用法?PHP sfForm::setOption怎么用?PHP sfForm::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::setOption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: embedDynamicRelation
/**
* Embeds a dynamic relation in a form.
*
* @param sfForm $form A form
* @param string $relationName A relation name and optional alias
* @param string $formClass A form class
* @param array $formArgs Arguments for the form constructor
*/
protected function embedDynamicRelation(sfForm $form, $relationName, $formClass = null, $formArgs = array())
{
// get relation and determine the field name to use for embedding
if (false !== ($pos = stripos($relationName, ' as '))) {
$relation = $form->getObject()->getTable()->getRelation(substr($relationName, 0, $pos));
$field = substr($relationName, $pos + 4);
} else {
$relation = $form->getObject()->getTable()->getRelation($relationName);
$field = sfInflector::underscore($relationName);
}
// validate relation type
if (Doctrine_Relation::MANY != $relation->getType()) {
throw new LogicException(sprintf('The %s "%s" relation is not a MANY relation.', get_class($form->getObject()), $relation->getAlias()));
}
// use the default form class
if (null === $formClass) {
$formClass = $relation->getClass() . 'Form';
}
// store configuration for this relation to the form
$config = $form->getOption('dynamic_relations');
$form->setOption('dynamic_relations', array_merge($config ? $config : array(), array($field => array('relation' => $relation, 'class' => $formClass, 'arguments' => $formArgs))));
// do the actual embedding
$this->doEmbed($form, $field, $form->getObject()->get($relation->getAlias()));
}
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:32,代码来源:sfDoctrineDynamicFormRelations.class.php
示例2: setFormEmbedded
/**
* Sets a sfForm as embedded by adding options
*
* @param sfForm $form the form to setup as embedded
* @return sfForm
*/
protected function setFormEmbedded(sfForm $form)
{
$form->setOption('is_embedded', true);
$form->setOption('embedder', $this);
return $form;
}