本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::isSubmitted方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::isSubmitted方法的具体用法?PHP FormStateInterface::isSubmitted怎么用?PHP FormStateInterface::isSubmitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormStateInterface
的用法示例。
在下文中一共展示了FormStateInterface::isSubmitted方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSubmitForm
/**
* {@inheritdoc}
*/
public function doSubmitForm(&$form, FormStateInterface &$form_state)
{
if (!$form_state->isSubmitted()) {
return;
}
// Execute form submit handlers.
$this->executeSubmitHandlers($form, $form_state);
// If batches were set in the submit handlers, we process them now,
// possibly ending execution. We make sure we do not react to the batch
// that is already being processed (if a batch operation performs a
// \Drupal\Core\Form\FormBuilderInterface::submitForm).
if (($batch =& $this->batchGet()) && !isset($batch['current_set'])) {
// Store $form_state information in the batch definition.
$batch['form_state'] = $form_state;
$batch['progressive'] = !$form_state->isProgrammed();
$response = batch_process();
if ($batch['progressive']) {
return $response;
}
// Execution continues only for programmatic forms.
// For 'regular' forms, we get redirected to the batch processing
// page. Form redirection will be handled in _batch_finished(),
// after the batch is processed.
}
// Set a flag to indicate the form has been processed and executed.
$form_state->setExecuted();
// If no response has been set, process the form redirect.
if (!$form_state->getResponse() && ($redirect = $this->redirectForm($form_state))) {
$form_state->setResponse($redirect);
}
// If there is a response was set, return it instead of continuing.
if (($response = $form_state->getResponse()) && $response instanceof Response) {
return $response;
}
}
示例2: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
// Only run key provider settings validation if the form is being submitted
if ($form_state->isSubmitted()) {
$plugin = $this->manager->createInstance($form_state->getValue('key_provider'), []);
$plugin->validateConfigurationForm($form, $form_state);
}
parent::validateForm($form, $form_state);
}
示例3: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
// Only run key settings validation if the form is being submitted
if ($form_state->isSubmitted()) {
$plugin_settings = (new FormState())->setValues($form_state->getValue('key_settings'));
$plugin = $this->manager->createInstance($form_state->getValue('key_provider'), []);
$plugin->validateConfigurationForm($form, $plugin_settings);
// Reinject errors from $plugin_settings into $form_state
foreach ($plugin_settings->getErrors() as $field => $error) {
$form_state->setErrorByName($field, $error);
}
}
parent::validateForm($form, $form_state);
}
示例4: isSubmitted
/**
* {@inheritdoc}
*/
public function isSubmitted()
{
return $this->mainFormState->isSubmitted();
}
示例5: determineLimitValidationErrors
/**
* Determines if validation errors should be limited.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array|null
*/
protected function determineLimitValidationErrors(FormStateInterface &$form_state)
{
// While this element is being validated, it may be desired that some
// calls to \Drupal\Core\Form\FormStateInterface::setErrorByName() be
// suppressed and not result in a form error, so that a button that
// implements low-risk functionality (such as "Previous" or "Add more") that
// doesn't require all user input to be valid can still have its submit
// handlers triggered. The triggering element's #limit_validation_errors
// property contains the information for which errors are needed, and all
// other errors are to be suppressed. The #limit_validation_errors property
// is ignored if submit handlers will run, but the element doesn't have a
// #submit property, because it's too large a security risk to have any
// invalid user input when executing form-level submit handlers.
$triggering_element = $form_state->getTriggeringElement();
if (isset($triggering_element['#limit_validation_errors']) && $triggering_element['#limit_validation_errors'] !== FALSE && !($form_state->isSubmitted() && !isset($triggering_element['#submit']))) {
return $triggering_element['#limit_validation_errors'];
} elseif ($triggering_element && !isset($triggering_element['#limit_validation_errors']) && !$form_state->isSubmitted()) {
return array();
} else {
return NULL;
}
}
示例6: getComponentList
//.........这里部分代码省略.........
foreach ($sections as $section) {
$component_export['_features_options'][$section] = array();
$component_export['_features_selected'][$section] = array();
}
if (!empty($component_info)) {
$exported_components = !empty($exported_features_info[$component]) ? $exported_features_info[$component] : array();
$new_components = !empty($new_features_info[$component]) ? $new_features_info[$component] : array();
foreach ($component_info as $key => $label) {
$config_name = $this->featuresManager->getFullName($component, $key);
// If checkbox in Sources is checked, move it to Added section.
if (!$form_state->isValueEmpty(array($component, 'sources', 'selected', $key))) {
$form_state->setValue(array($component, 'sources', 'selected', $key), FALSE);
$form_state->setValue(array($component, 'added', $key), 1);
$component_export['_features_options']['added'][$key] = $this->configLabel($component, $key, $label);
$component_export['_features_selected']['added'][$key] = $key;
// If this was previously excluded, we don't need to set it as
// required because it was automatically assigned.
if (isset($this->excluded[$component][$key])) {
unset($this->excluded[$component][$key]);
} else {
$this->required[$component][$key] = $key;
}
} elseif (isset($new_components[$key])) {
// Option is in the New exported array.
if (isset($exported_components[$key])) {
// Option was already previously exported so it's part of the
// Included checkboxes.
$section = 'included';
$default_value = $key;
// If Included item was un-selected (removed from export
// $config_new) but was re-detected in the $new_components
// means it was an auto-detect that was previously part of the
// export and is now de-selected in UI.
if ($form_state->isSubmitted() && ($form_state->hasValue(array($component, 'included', $key)) || $form_state->isValueEmpty(array($component, 'detected', $key))) && empty($config_new[$component][$key])) {
$section = 'detected';
$default_value = FALSE;
} elseif ($form_state->isSubmitted() && $form_state->isValueEmpty(array($component, 'added', $key)) && $form_state->isValueEmpty(array($component, 'detected', $key)) && $form_state->isValueEmpty(array($component, 'included', $key))) {
$section = 'added';
$default_value = FALSE;
}
} else {
// Option was in New exported array, but NOT in already exported
// so it's a user-selected or an auto-detect item.
$section = 'detected';
$default_value = NULL;
// Check for item explicitly excluded.
if (isset($this->excluded[$component][$key]) && !$form_state->hasValue(array($component, 'detected', $key))) {
$default_value = FALSE;
} else {
$default_value = $key;
}
// If it's already checked in Added or Sources, leave it in Added
// as checked.
if ($form_state->isSubmitted() && (!$form_state->isValueEmpty(array($component, 'added', $key)) || !$form_state->isValueEmpty(array($component, 'sources', 'selected', $key)))) {
$section = 'added';
$default_value = $key;
} elseif ($form_state->isSubmitted() && $form_state->isValueEmpty(array($component, 'sources', 'selected', $key)) && $form_state->isValueEmpty(array($component, 'detected', $key)) && !$form_state->hasValue(array($component, 'added', $key))) {
$section = 'detected';
$default_value = FALSE;
}
}
$component_export['_features_options'][$section][$key] = $this->configLabel($component, $key, $label);
$component_export['_features_selected'][$section][$key] = $default_value;
// Save which dependencies are specifically excluded from
// auto-detection.
if ($section == 'detected' && $default_value === FALSE) {
示例7: isSubmitted
/**
* {@inheritdoc}
*/
public function isSubmitted()
{
return $this->decoratedFormState->isSubmitted();
}
示例8: testIsSubmitted
/**
* @covers ::isSubmitted
*
* @dataProvider providerSingleBooleanArgument
*
* @param bool $submitted
*/
public function testIsSubmitted($submitted)
{
$this->decoratedFormState->isSubmitted()->willReturn($submitted);
$this->assertSame($submitted, $this->formStateDecoratorBase->isSubmitted());
}