本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Form\FormBuilder::getContextualId方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getContextualId方法的具体用法?PHP FormBuilder::getContextualId怎么用?PHP FormBuilder::getContextualId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anomaly\Streams\Platform\Ui\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getContextualId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guess
/**
* Guess some some form action parameters.
*
* @param FormBuilder $builder
*/
public function guess(FormBuilder $builder)
{
$actions = $builder->getActions();
$section = $this->sections->active();
reset($actions);
$first = key($actions);
foreach ($actions as $key => &$action) {
// If we already have an HREF then skip it.
if (isset($action['redirect'])) {
continue;
}
if ($key == $first && ($redirect = $builder->getOption('redirect'))) {
$action['redirect'] = $redirect;
continue;
}
// Determine the HREF based on the action type.
switch (array_get($action, 'action')) {
case 'save':
case 'submit':
case 'save_exit':
$action['redirect'] = $section ? $section->getHref() : $this->request->fullUrl();
break;
case 'update':
case 'save_edit':
case 'save_continue':
$action['redirect'] = function () use($section, $builder) {
if ($section && $builder->getFormMode() == 'create') {
return $section->getHref('edit/' . $builder->getContextualId());
}
return $this->request->fullUrl();
};
break;
case 'save_edit_next':
$ids = array_filter(explode(',', $builder->getRequestValue('edit_next')));
if (!$ids) {
$action['redirect'] = $section ? $section->getHref() : $this->request->fullUrl();
} elseif (count($ids) == 1) {
$action['redirect'] = $section ? $section->getHref('edit/' . array_shift($ids)) : $this->request->fullUrl();
} else {
$action['redirect'] = $section ? $section->getHref('edit/' . array_shift($ids) . '?' . $builder->getOption('prefix') . 'edit_next=' . implode(',', $ids)) : $this->request->fullUrl();
}
break;
}
}
$builder->setActions($actions);
}
示例2: guess
/**
* Guess some some form action parameters.
*
* @param FormBuilder $builder
*/
public function guess(FormBuilder $builder)
{
$actions = $builder->getActions();
$section = $this->sections->active();
reset($actions);
$first = key($actions);
foreach ($actions as $key => &$action) {
/*
* If we already have an
* HREF then skip it.
*/
if (isset($action['redirect'])) {
continue;
}
/*
* If this is the first action and the
* form builder has a redirect option
* then use it for the action redirect.
*/
if ($key == $first && ($redirect = $builder->getOption('redirect'))) {
$action['redirect'] = $redirect;
continue;
}
/*
* If we're not in admin then just assume we
* need to head back to the form. No redirect
* will redirect back in this case.
*/
if ($this->request->segment(1) !== 'admin') {
continue;
}
// Determine the HREF based on the action type.
switch (array_get($action, 'action')) {
case 'save':
case 'submit':
case 'save_exit':
$action['redirect'] = $section ? $section->getHref() : $this->request->fullUrl();
break;
case 'save_create':
$action['redirect'] = $this->request->fullUrl();
break;
case 'update':
case 'save_edit':
case 'save_continue':
$action['redirect'] = function () use($section, $builder) {
if ($section && $builder->getFormMode() == 'create') {
return $section->getHref('edit/' . $builder->getContextualId());
}
return $this->request->fullUrl();
};
break;
case 'save_edit_next':
$ids = array_filter(explode(',', $builder->getRequestValue('edit_next')));
if (!$ids) {
$action['redirect'] = $section ? $section->getHref() : $this->request->fullUrl();
} elseif (count($ids) == 1) {
$action['redirect'] = $section ? $section->getHref('edit/' . array_shift($ids)) : $this->request->fullUrl();
} else {
$action['redirect'] = $section ? $section->getHref('edit/' . array_shift($ids) . '?' . $builder->getOption('prefix') . 'edit_next=' . implode(',', $ids)) : $this->request->fullUrl();
}
break;
}
}
$builder->setActions($actions);
}