/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getTriggeringElement()['#name'] == 'select_id_submit') { $form_state->set('default_type', $form_state->getValue('id')); $form_state->setRebuild(); } else { parent::submitForm($form, $form_state); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Get an array of strings with the permissions names. $permissions = array_keys(array_filter($form_state->getValue('permissions'))); $form_state->setValue('permissions', $permissions); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $plugin = $this->manager->createInstance($form_state->getValue('key_provider'), []); $plugin->submitConfigurationForm($form, $form_state); $form_state->setValue('key_provider_settings', $plugin->getConfiguration()); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $target_entity = $form_state->getValue('entity'); $target_bundle = $form_state->getValue('bundle', $target_entity); $this->entity->set('target_entity_type', $target_entity); $this->entity->set('target_bundle', $target_bundle); if ($target_entity !== $target_bundle) { drupal_set_message($this->t('A entity layout for the @entity entity and @bundle bundle has been created.', ['@entity' => $this->entityLayoutService->getTargetEntityLabel($this->entity), '@bundle' => $this->entityLayoutService->getTargetBundleLabel($this->entity)])); } else { drupal_set_message($this->t('A entity layout for the @entity entity has been created.', ['@entity' => $this->entityLayoutService->getTargetEntityLabel($this->entity)])); } $form_state->setRedirectUrl($this->entity->toUrl('collection')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $facet_source = $this->getEntity(); drupal_set_message($this->t('Facet source %name has been saved.', ['%name' => $facet_source->label()])); $form_state->setRedirect('facets.overview'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Allow the variant to submit the form. $variant_plugin_values = (new FormState())->setValues($form_state->getValue('variant_settings')); $this->getVariantPlugin()->submitConfigurationForm($form, $variant_plugin_values); // Make sure the Panels storage is set correctly before saving. $this->setPanelsStorage($this->getVariantPlugin()); // Update the original form values. $form_state->setValue('variant_settings', $variant_plugin_values->getValues()); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); // Handle the default value. $default_value = array(); if (isset($form['default_value'])) { $items = $form['#entity']->get($this->entity->getName()); $default_value = $items->defaultValuesFormSubmit($form['default_value'], $form, $form_state); } $this->entity->default_value = $default_value; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); if (!$this->entity->isNew() || $this->entity->isLocked()) { $this->submitOverviewForm($form, $form_state); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); /** @var $index \Drupal\search_api\IndexInterface */ $index = $this->getEntity(); $index->setOptions($form_state->getValue('options', array()) + $this->originalEntity->getOptions()); $datasources = $form_state->getValue('datasources', array()); /** @var \Drupal\search_api\Datasource\DatasourceInterface[] $datasource_plugins */ $datasource_plugins = $this->originalEntity->getDatasources(FALSE); $datasource_configuration = array(); foreach ($datasources as $datasource_id) { $datasource = $datasource_plugins[$datasource_id]; $datasource_form = !empty($form['datasource_configs'][$datasource_id]) ? $form['datasource_configs'][$datasource_id] : array(); $datasource_form_state = new SubFormState($form_state, array('datasource_configs', $datasource_id)); $datasource->submitConfigurationForm($datasource_form, $datasource_form_state); $datasource_configuration[$datasource_id] = $datasource->getConfiguration(); } $index->set('datasource_configs', $datasource_configuration); // Call submitConfigurationForm() for the (possibly new) tracker. // @todo It seems if we change the tracker, we would validate/submit the old // tracker's form using the new tracker. Shouldn't be done, of course. // Similar above for datasources, though there of course the values will // just always be empty (because datasources have their plugin ID in the // form structure). $tracker_id = $form_state->getValue('tracker', NULL); if ($this->originalEntity->getTrackerId() == $tracker_id) { $tracker = $this->originalEntity->getTracker(); } else { $tracker = $this->trackerPluginManager->createInstance($tracker_id, array('index' => $this->originalEntity)); } $tracker_form_state = new SubFormState($form_state, array('tracker_config')); $tracker->submitConfigurationForm($form['tracker_config'], $tracker_form_state); $index->set('tracker_config', $tracker->getConfiguration()); // Invalidate caches, so this gets picked up by the views wizard. Cache::invalidateTags(array('views_data')); // Remove this line when https://www.drupal.org/node/2370365 gets fixed. Cache::invalidateTags(array('extension:views')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); // Add the submitted form values to the text format, and save it. $format = $this->entity; foreach ($form_state->getValues() as $key => $value) { if ($key != 'filters') { $format->set($key, $value); } else { foreach ($value as $instance_id => $config) { $format->setFilterConfig($instance_id, $config); } } } $format->save(); // Save user permissions. if ($permission = $format->getPermissionName()) { foreach ($form_state->getValue('roles') as $rid => $enabled) { user_role_change_permissions($rid, array($permission => $enabled)); } } $form_state->setRedirect('filter.admin_overview'); return $this->entity; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $this->plugin->submitConfigurationForm($form['settings'], $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); /** @var \Drupal\search_api\ServerInterface $server */ $authorization_profile = $this->getEntity(); // Check before loading the provider plugin so we don't throw an exception. if ($form['provider_config']['#type'] == 'details' && $authorization_profile->hasValidProvider()) { $provider_form_state = new SubFormState($form_state, array('provider_config')); $authorization_profile->getProvider()->submitConfigurationForm($form['provider_config'], $provider_form_state); } // Check before loading the consumer plugin so we don't throw an exception. if ($form['consumer_config']['#type'] == 'details' && $authorization_profile->hasValidConsumer()) { $consumer_form_state = new SubFormState($form_state, array('consumer_config')); $authorization_profile->getConsumer()->submitConfigurationForm($form['consumer_config'], $consumer_form_state); } // @TODO Submit Row forms if ($form['mappings']) { $mappings_form_state = new SubFormState($form_state, array('mappings')); $authorization_profile->getConsumer()->submitRowForm($form['mappings'], $mappings_form_state); $authorization_profile->getProvider()->submitRowForm($form['mappings'], $mappings_form_state); // Move provider_mappings to the top level // @TODO fix this. Why do we have to do it? Why doesn't it work? $values = $form_state->getValues(); $values['provider_mappings'] = $values['mappings']['provider_mappings']; unset($values['mappings']['provider_mappings']); $values['consumer_mappings'] = $values['mappings']['consumer_mappings']; unset($values['mappings']['consumer_mappings']); $form_state->setValues($values); // @TODO shouldn't have to do this. Though the above doesn't work either. // @TODO should validate beforehand to make sure that we have mappings. if ($values['provider_mappings']) { $authorization_profile->setProviderMappings($values['provider_mappings']); } if ($values['consumer_mappings']) { $authorization_profile->setConsumerMappings($values['consumer_mappings']); } } return $authorization_profile; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->getParentPaymentStatusSelector($form_state)->submitSelectorForm($form['parent_id'], $form_state); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Submit plugin configuration if available. if ($plugin = $this->entity->getEncryptionMethod()) { if ($plugin instanceof EncryptionMethodPluginFormInterface) { $plugin_form_state = $this->createPluginFormState($form_state); $plugin->submitConfigurationForm($form, $plugin_form_state); $form_state->setValue('encryption_method_configuration', $plugin_form_state->getValues()); } } parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { /** @var \Drupal\payment\Plugin\Payment\MethodConfiguration\PaymentMethodConfigurationInterface $payment_method_configuration */ $payment_method_configuration = $form_state->get('payment_method_configuration'); $payment_method_configuration->submitConfigurationForm($form['plugin_form'], $form_state); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Allow the variant to submit the form. $variant_plugin_values = (new FormState())->setValues($form_state->getValue('variant_settings')); $this->getVariantPlugin()->submitConfigurationForm($form, $variant_plugin_values); // Update the original form values. $form_state->setValue('variant_settings', $variant_plugin_values->getValues()); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $entity = $this->entity; // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for submission. // @todo Find a way to avoid this manipulation. $settings = (new FormState())->setValues($form_state->getValue('settings')); // Call the plugin submit handler. $entity->getPlugin()->submitConfigurationForm($form, $settings); // Update the original form values. $form_state->setValue('settings', $settings->getValues()); // Save the settings of the plugin. $entity->save(); drupal_set_message($this->t('The block configuration has been saved.')); $form_state->setRedirect('block.admin_display_theme', array('theme' => $form_state->getValue('theme')), array('query' => array('block-placement' => drupal_html_class($this->entity->id())))); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); // Set protected entity ID. $entity_id = $form_state->getValue('entity_id'); $this->entity->setProtectedEntityId($entity_id); // Set enabled plugins. foreach ($form_state->getValue('protection') as $instance_id => $enabled) { if ($enabled) { $this->entity->enableProtection($instance_id); } else { $this->entity->disableProtection($instance_id); } } // Set bypass roles. $bypass_roles = array(); foreach ($form_state->getValue('bypass_roles') as $rid => $status) { if (!empty($status)) { $bypass_roles[] = $rid; } } $this->entity->setBypassRoles($bypass_roles); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $entity = $this->entity; // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for submission. $sub_form_state = SubformState::createForSubform($form['settings'], $form, $form_state); // Call the plugin submit handler. $block = $entity->getPlugin(); $this->getPluginForm($block)->submitConfigurationForm($form, $sub_form_state); // If this block is context-aware, set the context mapping. if ($block instanceof ContextAwarePluginInterface && $block->getContextDefinitions()) { $context_mapping = $sub_form_state->getValue('context_mapping', []); $block->setContextMapping($context_mapping); } $this->submitVisibility($form, $form_state); // Save the settings of the plugin. $entity->save(); drupal_set_message($this->t('The block configuration has been saved.')); $form_state->setRedirect('block.admin_display_theme', array('theme' => $form_state->getValue('theme')), array('query' => array('block-placement' => Html::getClass($this->entity->id())))); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); /** @var \Drupal\facets\FacetInterface $facet */ $facet = $this->getEntity(); $is_new = $facet->isNew(); if ($is_new) { // On facet creation, enable all locked processors by default, using their // default settings. $stages = $this->getProcessorPluginManager()->getProcessingStages(); $processors_definitions = $this->getProcessorPluginManager()->getDefinitions(); foreach ($processors_definitions as $processor_id => $processor) { $is_locked = isset($processor['locked']) && $processor['locked'] == TRUE; $is_default_enabled = isset($processor['default_enabled']) && $processor['default_enabled'] == TRUE; if ($is_locked || $is_default_enabled) { $weights = []; foreach ($stages as $stage_id => $stage) { if (isset($processor['stages'][$stage_id])) { $weights[$stage_id] = $processor['stages'][$stage_id]; } } $facet->addProcessor(['processor_id' => $processor_id, 'weights' => $weights, 'settings' => []]); } } // Set a default widget for new facets. $facet->setWidget('links'); $facet->setUrlAlias($form_state->getValue('id')); $facet->setWeight(0); // Set default empty behaviour. $facet->setEmptyBehavior(['behavior' => 'none']); $facet->setOnlyVisibleWhenFacetSourceIsVisible(TRUE); } $facet_source_id = $form_state->getValue('facet_source_id'); if (!is_null($facet_source_id) && $facet_source_id !== '') { /** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */ $facet_source = $this->getFacetSourcePluginManager()->createInstance($facet_source_id, ['facet' => $this->getEntity()]); $facet_source->submitConfigurationForm($form, $form_state); } $facet->save(); // Ensure that the caching of the view display is disabled, so the search // correctly returns the facets. Only apply this when the facet source is // actually a view by exploding on :. list($type, ) = explode(':', $facet_source_id); if ($type === 'search_api_views') { list(, $view_id, $display) = explode(':', $facet_source_id); } if (isset($view_id)) { $view = Views::getView($view_id); $view->setDisplay($display); $view->display_handler->overrideOption('cache', ['type' => 'none']); $view->save(); $display_plugin = $view->getDisplay()->getPluginId(); } if ($is_new) { if (\Drupal::moduleHandler()->moduleExists('block')) { $message = $this->t('Facet %name has been created. Go to the <a href=":block_overview">Block overview page</a> to place the new block in the desired region.', ['%name' => $facet->getName(), ':block_overview' => \Drupal::urlGenerator()->generateFromRoute('block.admin_display')]); drupal_set_message($message); $form_state->setRedirect('entity.facets_facet.edit_form', ['facets_facet' => $facet->id()]); } if (isset($view_id) && $display_plugin === 'block') { $facet->setOnlyVisibleWhenFacetSourceIsVisible(FALSE); } } else { drupal_set_message(t('Facet %name has been updated.', ['%name' => $facet->getName()])); } // Clear Drupal cache for blocks to reflect recent changes. \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); return $facet; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); /** @var \Drupal\crm_core_match\Entity\Matcher $matcher */ $matcher = $this->entity; $plugin = $matcher->getPlugin(); $plugin->submitConfigurationForm($form, $form_state); drupal_set_message($this->t('The configuration has been saved.')); $form_state->setRedirect('entity.crm_core_match.edit_form', ['crm_core_match' => $matcher->id()]); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); foreach ($form_state->getValue(['members']) as $member_index => $values) { $member_form = $form['members'][$member_index]['form']; $member = $member_form['#member']; $member_form_state = $this->buildMemberFormState($member_form['#parents'], $form_state); $member->submitConfigurationForm($member_form, $member_form_state); // Update form state with values that might have been changed by the plugin. $form_state->setValue($member_form['#parents'], $member_form_state->getValues()); // Update the member weight. $configuration = $member->getConfiguration(); $configuration['weight'] = $values['weight']; $member->setConfiguration($configuration); // Update the member on the entity. $this->entity->getMembers()->addInstanceId($member->getId(), $configuration); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // If moderation is enabled, revisions MUST be enabled as well. // Otherwise we can't have forward revisions. if ($form_state->getValue('enable_moderation_state')) { /* @var ConfigEntityTypeInterface $bundle */ $bundle = $form_state->getFormObject()->getEntity(); $this->entityTypeManager->getHandler($bundle->getEntityType()->getBundleOf(), 'moderation')->onBundleModerationConfigurationFormSubmit($bundle); } parent::submitForm($form, $form_state); drupal_set_message($this->t('Your settings have been saved.')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $entity = $this->entity; // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for submission. // @todo Find a way to avoid this manipulation. $settings = (new FormState())->setValues($form_state->getValue('settings')); // Call the plugin submit handler. $entity->getPlugin()->submitConfigurationForm($form, $settings); // Update the original form values. $form_state->setValue('settings', $settings->getValues()); // Submit visibility condition settings. foreach ($form_state->getValue('visibility') as $condition_id => $values) { // Allow the condition to submit the form. $condition = $form_state->get(['conditions', $condition_id]); $condition_values = (new FormState())->setValues($values); $condition->submitConfigurationForm($form, $condition_values); if ($condition instanceof ContextAwarePluginInterface) { $context_mapping = isset($values['context_mapping']) ? $values['context_mapping'] : []; $condition->setContextMapping($context_mapping); } // Update the original form values. $condition_configuration = $condition->getConfiguration(); $form_state->setValue(['visibility', $condition_id], $condition_configuration); // Update the visibility conditions on the block. $entity->getVisibilityConditions()->addInstanceId($condition_id, $condition_configuration); } // Save the settings of the plugin. $entity->save(); drupal_set_message($this->t('The block configuration has been saved.')); $form_state->setRedirect('block.admin_display_theme', array('theme' => $form_state->getValue('theme')), array('query' => array('block-placement' => Html::getClass($this->entity->id())))); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); if ($this->plugin instanceof PluginFormInterface) { $this->plugin->submitConfigurationForm($form, $form_state); } return $this->entity; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); /** @var \Drupal\search_api\ServerInterface $server */ $server = $this->getEntity(); // Check before loading the backend plugin so we don't throw an exception. if ($form['backend_config']['#type'] == 'details' && $server->hasValidBackend()) { $backend_form_state = new SubFormState($form_state, array('backend_config')); $server->getBackend()->submitConfigurationForm($form['backend_config'], $backend_form_state); } return $server; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // If the main "Save" button was submitted while a field settings subform // was being edited, update the new incoming settings when rebuilding the // entity, just as if the subform's "Update" button had been submitted. if ($edit_field = $form_state->get('plugin_settings_edit')) { $form_state->set('plugin_settings_update', $edit_field); } parent::submitForm($form, $form_state); $form_values = $form_state->getValues(); // Handle the 'display modes' checkboxes if present. if ($this->entity->getMode() == 'default' && !empty($form_values['display_modes_custom'])) { $display_modes = $this->getDisplayModes(); $current_statuses = $this->getDisplayStatuses(); $statuses = array(); foreach ($form_values['display_modes_custom'] as $mode => $value) { if (!empty($value) && empty($current_statuses[$mode])) { // If no display exists for the newly enabled view mode, initialize // it with those from the 'default' view mode, which were used so // far. if (!$this->entityManager->getStorage($this->entity->getEntityTypeId())->load($this->entity->getTargetEntityTypeId() . '.' . $this->entity->getTargetBundle() . '.' . $mode)) { $display = $this->getEntityDisplay($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle(), 'default')->createCopy($mode); $display->save(); } $display_mode_label = $display_modes[$mode]['label']; $url = $this->getOverviewUrl($mode); drupal_set_message($this->t('The %display_mode mode now uses custom display settings. You might want to <a href=":url">configure them</a>.', ['%display_mode' => $display_mode_label, ':url' => $url->toString()])); } $statuses[$mode] = !empty($value); } $this->saveDisplayStatuses($statuses); } drupal_set_message($this->t('Your settings have been saved.')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); // Update the changed timestamp of the entity. $this->updateChangedTime($this->entity); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->setValue('pattern', trim($form_state->getValue('date_format_pattern'))); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($this->getConfigurablePlugins() as $type => $plugin) { $plugin_state = $this->createSubFormState($type . '_configuration', $form_state); $plugin->submitConfigurationForm($form[$type . '_configuration'], $plugin_state); $form_state->setValue($type . '_configuration', $plugin_state->getValues()); } parent::submitForm($form, $form_state); }