本文整理汇总了PHP中Drupal\Core\Form\FormState::addBuildInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP FormState::addBuildInfo方法的具体用法?PHP FormState::addBuildInfo怎么用?PHP FormState::addBuildInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormState
的用法示例。
在下文中一共展示了FormState::addBuildInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildChildFormState
/**
* Build all necessary things for child form (form state, etc.).
*
* @param \Drupal\Core\Entity\EntityFormInterface $controller
* Entity form controller for child form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Parent form state object.
* @param \Drupal\Core\Entity\EntityInterface $entity
* Entity object.
* @param string $operation
* Operation that is to be performed in inline form.
* @param array $parents
* Entity form #parents.
*
* @return \Drupal\Core\Form\FormStateInterface
* Child form state object.
*/
public static function buildChildFormState(EntityFormInterface $controller, FormStateInterface $form_state, EntityInterface $entity, $operation, $parents) {
$child_form_state = new FormState();
$child_form_state->addBuildInfo('callback_object', $controller);
$child_form_state->addBuildInfo('base_form_id', $controller->getBaseFormID());
$child_form_state->addBuildInfo('form_id', $controller->getFormID());
$child_form_state->addBuildInfo('args', array());
// Copy values to child form.
$child_form_state->setCompleteForm($form_state->getCompleteForm());
$child_form_state->setUserInput($form_state->getUserInput());
// Filter out all submitted values that are not directly relevant for this
// IEF. Otherwise they might mess things up.
$form_state_values = $form_state->getValues();
$form_state_values = static::extractArraySequence($form_state_values, $parents);
$child_form_state->setValues($form_state_values);
$child_form_state->setStorage($form_state->getStorage());
$value = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load($entity->getEntityTypeId() . '.' . $entity->bundle() . '.' . $operation);
$child_form_state->set('form_display', $value);
// Since some of the submit handlers are run, redirects need to be disabled.
$child_form_state->disableRedirect();
// When a form is rebuilt after Ajax processing, its #build_id and #action
// should not change.
// @see drupal_rebuild_form()
$rebuild_info = $child_form_state->getRebuildInfo();
$rebuild_info['copy']['#build_id'] = TRUE;
$rebuild_info['copy']['#action'] = TRUE;
$child_form_state->setRebuildInfo($rebuild_info);
$child_form_state->set('inline_entity_form', $form_state->get('inline_entity_form'));
$child_form_state->set('langcode', $entity->language()->getId());
$child_form_state->set('field', $form_state->get('field'));
$child_form_state->setTriggeringElement($form_state->getTriggeringElement());
$child_form_state->setSubmitHandlers($form_state->getSubmitHandlers());
return $child_form_state;
}
示例2: testInstallConfigureForm
/**
* Tests the root user account form section in the "Configure site" form.
*/
function testInstallConfigureForm()
{
require_once \Drupal::root() . '/core/includes/install.core.inc';
require_once \Drupal::root() . '/core/includes/install.inc';
$install_state = install_state_defaults();
$form_state = new FormState();
$form_state->addBuildInfo('args', [&$install_state]);
$form = $this->container->get('form_builder')->buildForm('Drupal\\Core\\Installer\\Form\\SiteConfigureForm', $form_state);
// Verify name and pass field order.
$this->assertFieldOrder($form['admin_account']['account']);
// Verify that web browsers may autocomplete the email value and
// autofill/prefill the name and pass values.
foreach (array('mail', 'name', 'pass') as $key) {
$this->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'{$key}' field: 'autocomplete' attribute not found.");
}
}
示例3: getForm
/**
* {@inheritdoc}
*/
public function getForm($form_arg)
{
$form_state = new FormState();
$args = func_get_args();
// Remove $form_arg from the arguments.
unset($args[0]);
$form_state->addBuildInfo('args', array_values($args));
return $this->buildForm($form_arg, $form_state);
}
示例4: buildChildFormState
/**
* Build all necessary things for child form (form state, etc.).
*
* @param \Drupal\Core\Entity\EntityFormInterface $controller
* Entity form controller for child form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Parent form state object.
* @param \Drupal\Core\Entity\EntityInterface $entity
* Entity object.
* @param string $operation
* Operation that is to be performed in inline form.
*
* @return \Drupal\Core\Form\FormStateInterface
* Child form state object.
*/
public static function buildChildFormState(EntityFormInterface $controller, FormStateInterface $form_state, EntityInterface $entity, $operation)
{
$child_form_state = new FormState();
$child_form_state->addBuildInfo('callback_object', $controller);
$child_form_state->addBuildInfo('base_form_id', $controller->getBaseFormID());
$child_form_state->addBuildInfo('form_id', $controller->getFormID());
$child_form_state->addBuildInfo('args', array());
// Copy values to child form.
$child_form_state->setUserInput($form_state->getUserInput());
$child_form_state->setValues($form_state->getValues());
$child_form_state->setStorage($form_state->getStorage());
$child_form_state->set('form_display', entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), $operation));
// Since some of the submit handlers are run, redirects need to be disabled.
$child_form_state->disableRedirect();
// When a form is rebuilt after Ajax processing, its #build_id and #action
// should not change.
// @see drupal_rebuild_form()
$rebuild_info = $child_form_state->getRebuildInfo();
$rebuild_info['copy']['#build_id'] = TRUE;
$rebuild_info['copy']['#action'] = TRUE;
$child_form_state->setRebuildInfo($rebuild_info);
$child_form_state->set('inline_entity_form', $form_state->get('inline_entity_form'));
$child_form_state->set('langcode', $entity->language()->getId());
$child_form_state->set('field', $form_state->get('field'));
$child_form_state->setTriggeringElement($form_state->getTriggeringElement());
$child_form_state->setSubmitHandlers($form_state->getSubmitHandlers());
return $child_form_state;
}
示例5: getFormState
/**
* Get the wizard form state.
*
* @param \Drupal\ctools\Wizard\FormWizardInterface $wizard
* The form wizard.
* @param array $parameters
* The array of parameters specific to this wizard.
* @param bool $ajax
*
* @return \Drupal\Core\Form\FormState
*/
public function getFormState(FormWizardInterface $wizard, array $parameters, $ajax = FALSE)
{
$form_state = new FormState();
// If a wizard has no values, initialize them.
if (!$wizard->getTempstore()->get($wizard->getMachineName())) {
$cached_values = $wizard->initValues();
// Save the cached values that were initialized.
//$wizard->getTempstore()->set($wizard->getMachineName(), $cached_values);
} else {
$cached_values = $wizard->getTempstore()->get($wizard->getMachineName());
}
$form_state->setTemporaryValue('wizard', $cached_values);
$form_state->set('ajax', $ajax);
$parameters['form'] = [];
$parameters['form_state'] = $form_state;
$method = new \ReflectionMethod($wizard, 'buildForm');
$arguments = [];
foreach ($method->getParameters() as $parameter) {
if (array_key_exists($parameter->name, $parameters)) {
$arguments[] = $parameters[$parameter->name];
} elseif ($parameter->isDefaultValueAvailable()) {
$arguments[] = $parameter->getDefaultValue();
}
}
unset($parameters['form'], $parameters['form_state']);
// Remove $form and $form_state from the arguments, and re-index them.
unset($arguments[0], $arguments[1]);
$form_state->addBuildInfo('args', array_values($arguments));
return $form_state;
}