/**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove Form API elements from $form_state
     $form_state->cleanValues();
     db_merge('uc_attributes')->key(array('aid' => $form_state->getValue('aid')))->fields($form_state->getValues())->execute();
     $form_state->setRedirect('uc_attribute.overview');
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     // This won't have a proper JSON header, but Drupal doesn't check for that
     // anyway so this is fine until it's replaced with a JsonResponse.
     print Json::encode($form_state->getValues());
     exit;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove Form API elements from $form_state
     $form_state->cleanValues();
     db_merge('uc_attribute_options')->key(array('aid' => $form_state->getValue('aid'), 'oid' => $form_state->getValue('oid')))->fields($form_state->getValues())->execute();
     drupal_set_message($this->t('Updated option %option.', ['%option' => $form_state->getValue('name')]));
     $this->logger('uc_attribute')->notice('Updated option %option.', ['%option' => $form_state->getValue('name'), 'link' => 'admin/store/products/attributes/' . $form_state->getValue('aid') . '/options/' . $form_state->getValue('oid')]);
     $form_state->setRedirect('uc_attribute.options', ['aid' => $form_state->getValue('aid')]);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $builder = $this->createBuilder($form_state->getValue('builder_id'));
     $values = $form_state->cleanValues()->getValues();
     $view = $builder->createView($values);
     $view->save();
     // Redirect the user to the view admin form.
     $form_state->setRedirectUrl($view->toUrl('edit-form'));
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->config('better_formats.settings');
     $form_state->cleanValues();
     foreach ($form_state->getValues() as $key => $value) {
         $config->set($key, $value);
     }
     $config->save();
     parent::submitForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove Form API elements from $form_state
     $form_state->cleanValues();
     $aid = db_insert('uc_attributes')->fields($form_state->getValues())->execute();
     if ($form_state->getValue('display') == 0) {
         // No options needed/allowed for Textfield display type.
         $form_state->setRedirect('uc_attribute.overview', ['aid' => $aid]);
     } else {
         // All other display types we redirect to add options.
         $form_state->setRedirect('uc_attribute.options', ['aid' => $aid]);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $node = $form['#node'];
     /** @var \Drupal\webform\ComponentBase $component */
     $component = $form['#component'];
     $values = $form_state->cleanValues()->getValues();
     $component->setConfiguration($values);
     $component->save();
     drupal_set_message($this->t('Changes to the webform have been saved.'));
     $config = $component->getConfiguration();
     // @todo Is value actually being used in the form after save()?
     $form['cid'] = array('#type' => 'value', '#value' => $config['cid']);
     $form_state->setRedirect('webform.components', array('node' => $node->id()));
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $admin = $form_state->getValue('administer_users');
     if (!\Drupal::config('user.settings')->get('verify_mail') || $admin) {
         $pass = $form_state->getValue('pass');
     } else {
         $pass = user_password();
     }
     // Remove unneeded values.
     $form_state->cleanValues();
     $form_state->setValue('pass', $pass);
     $form_state->setValue('init', $form_state->getValue('mail'));
     parent::submitForm($form, $form_state);
 }
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $values = $form_state->cleanValues()->getValues();

    $config = $this->configFactory()->getEditable('eform.type_defaults');
    $keys = array_keys($config->getRawData());
    foreach ($keys as $key) {
      $config->clear($key);
    }

    foreach ($values as $key => $value) {
      $config->set($key, $value);
    }
    $config->save();

    parent::submitForm($form, $form_state);
  }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     if ($form_state->hasValue('mid')) {
         db_merge('uc_weightquote_methods')->key(array('mid' => $form_state->getValue('mid')))->fields($form_state->getValues())->execute();
         drupal_set_message(t('Weight quote shipping method was updated.'));
         $form_state->setRedirect('uc_quote.methods');
     } else {
         db_insert('uc_weightquote_methods')->fields($form_state->getValues())->execute();
         // Ensure Rules picks up the new condition.
         // entity_flush_caches();
         drupal_set_message(t('Created and enabled new weight quote shipping method.'));
         $form_state->setRedirect('uc_quote.methods');
         //$form_state['redirect'] = 'admin/store/config/quotes/manage/get_quote_from_weightquote_' . $form_state->getValue('mid');
     }
 }
Example #11
0
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->cleanValues();
    $plugin_data = (new FormState())->setValues($form_state->getValues());
    $this->linkitMatcher->submitConfigurationForm($form, $plugin_data);
    $this->linkitProfile->save();

    drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->linkitMatcher->getLabel())));
    $this->logger('linkit')->notice('The matcher %label has been updated in the @profile profile.', [
      '%label' => $this->linkitMatcher->getLabel(),
      '@profile' => $this->linkitProfile->label(),
    ]);

    $form_state->setRedirect('linkit.matchers', [
      'linkit_profile' => $this->linkitProfile->id(),
    ]);
  }
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->cleanValues();

    /** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */
    $fillpdf_form = $this->getEntity();

    $mappings = $form_state->getValue('mappings');

    /** @var \Drupal\fillpdf\FillPdfFormInterface $imported_form */
    $imported_form = $mappings['form'];

    /** @var array $imported_fields */
    $imported_fields = $mappings['fields'];

    $unmatched_pdf_keys = $this->serializer->importForm($fillpdf_form, $imported_form, $imported_fields);

    foreach ($unmatched_pdf_keys as $unmatched_pdf_key) {
      drupal_set_message($this->t('Your code contained field mappings for the PDF field key <em>@pdf_key</em>, but it does not exist on this form. Therefore, it was ignored.', ['@pdf_key' => $unmatched_pdf_key]), 'warning');
    }

    drupal_set_message($this->t('Successfully imported FillPDF form configuration and matching PDF field keys. If any field mappings failed to import, they are listed above.'));

    $form_state->setRedirect('entity.fillpdf_form.edit_form', ['fillpdf_form' => $fillpdf_form->id()]);
  }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     $layout_blocks = $form_state->getValue('layout', []);
     if (!is_array($layout_blocks)) {
         $layout_blocks = [];
     }
     // If no content blocks has been created for this entity then we need to
     // transfer the default blocks to the loaded content entity as entity
     // layout blocks.
     if (!$this->entityLayoutService->hasContentBlocks($this->entity, $this->contentEntity)) {
         $block_collection = $this->entity->getDefaultBlocks();
         // Update the default blocks with new configuration values from the
         // form state before transferring the blocks since weights may have
         // been changed.
         foreach ($layout_blocks as $layout_block_id => $layout_block_configuration) {
             $configuration = $block_collection->get($layout_block_id)->getConfiguration();
             $block_collection->setInstanceConfiguration($layout_block_id, $layout_block_configuration + $configuration);
         }
         $this->entityLayoutService->transferBlocks($this->entity, $this->contentEntity, $block_collection);
     } else {
         $content_blocks = $this->entityLayoutService->getContentBlocksByEntity($this->contentEntity);
         foreach ($layout_blocks as $layout_block_id => $layout_block_configuration) {
             foreach ($content_blocks as $content_block) {
                 if ($layout_block_id !== $content_block->uuid()) {
                     continue;
                 }
                 $content_block->updateBlock($layout_block_configuration);
                 $content_block->save();
             }
         }
     }
     drupal_set_message($this->t('The layout for @label has been saved.', ['@label' => $this->contentEntity->label()]));
 }
 /**
  * @covers ::cleanValues
  */
 public function testCleanValues()
 {
     $this->decoratedFormState->cleanValues()->shouldBeCalled();
     $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->cleanValues());
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     // The image effect configuration is stored in the 'data' key in the form,
     // pass that through for submission.
     $effect_data = (new FormState())->setValues($form_state->getValue('data'));
     $this->imageEffect->submitConfigurationForm($form, $effect_data);
     // Update the original form values.
     $form_state->setValue('data', $effect_data->getValues());
     $this->imageEffect->setWeight($form_state->getValue('weight'));
     if (!$this->imageEffect->getUuid()) {
         $this->imageStyle->addImageEffect($this->imageEffect->getConfiguration());
     }
     $this->imageStyle->save();
     drupal_set_message($this->t('The image effect was successfully applied.'));
     $form_state->setRedirectUrl($this->imageStyle->urlInfo('edit-form'));
 }
 /**
  * Form submission handler.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $sitemap = \Drupal::service('custom_sitemap.sitemap');
     $entity_types = $sitemap->get_entity_types();
     $form_state->cleanValues();
     foreach ($form_state->getValues() as $setting => $value) {
         $setting_keys = explode('-', $setting);
         $entity_types[$setting_keys[0]][$setting_keys[1]][$setting_keys[2]] = $value;
     }
     $sitemap->save_entity_types($entity_types);
     $sitemap->generate_all_sitemaps();
     parent::submitForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     $this->settings->submitForm($form, $form_state);
     return parent::submitForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function cleanValues()
 {
     $this->decoratedFormState->cleanValues();
     return $this;
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state_values = $form_state->cleanValues()->getValues();
     if (!empty($form_state_values)) {
         $error = FALSE;
         $items = $form['#items'];
         $node = $form['#node'];
         if (!empty($items)) {
             foreach ($items as $delta => $item) {
                 $item_values = $item->getValue();
                 // compare the submitted answers with the correct answers
                 // all correct answers should be answered correct - there are no differences between correct and given answers allowed
                 // if the answer is available
                 if (isset($form_state_values['item_' . $delta])) {
                     // if the answer is different with the correct one
                     if ($form_state_values['item_' . $delta] != $item_values['correct']) {
                         $error = TRUE;
                     }
                 } else {
                     // no answer available for this delta - but should be there - error in the system
                     $error = TRUE;
                 }
             }
         }
         // if user answered wrong
         if ($error) {
             // redirect the user to the sorry page
             $url = new Url('field_quiz.sorry', array('node' => $node->id()));
             $form_state->setRedirectUrl($url);
         } else {
             // redirect the user to the success page
             $url = new Url('field_quiz.success', array('node' => $node->id()));
             $form_state->setRedirectUrl($url);
         }
     }
 }
 /**
  * Form submission handler.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $sitemap = \Drupal::service('custom_sitemap.sitemap');
     $custom_links = $sitemap->get_custom_links();
     $form_state->cleanValues();
     $custom_links[$form_state->getValue('name')] = array('path' => $form_state->getValue('path'), 'index' => (bool) $form_state->getValue('index'), 'priority' => (double) $form_state->getValue('priority'));
     $sitemap->save_custom_links($custom_links);
     $sitemap->generate_all_sitemaps();
     if ($form_state->getFormObject()->getFormId() == 'custom_sitemap_add_link_form') {
         drupal_set_message($this->t('The custom link has been added to the sitemap.'));
     } else {
         drupal_set_message($this->t('The custom link has been saved.'));
     }
     $form_state->setRedirect('custom_sitemap.overview');
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     print t('You WIN!');
     exit;
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->config('pathauto.settings');
     $form_state->cleanValues();
     $original_entity_types = $config->get('enabled_entity_types');
     foreach ($form_state->getValues() as $key => $value) {
         if ($key == 'enabled_entity_types') {
             $enabled_entity_types = [];
             foreach ($value as $entity_type_id => $enabled) {
                 $field_definitions = $this->entityFieldManager->getBaseFieldDefinitions($entity_type_id);
                 // Verify that the entity type is enabled and that it is not defined
                 // or defined by us before adding it to the configuration, so that
                 // we do not store an entity type that cannot be enabled or disabled.
                 if ($enabled && (!isset($field_definitions['path']) || $field_definitions['path']->getProvider() === 'pathauto')) {
                     $enabled_entity_types[] = $entity_type_id;
                 }
             }
             $value = $enabled_entity_types;
         }
         $config->set($key, $value);
     }
     $config->save();
     // Clear cached field definitions if the values are changed.
     if ($original_entity_types != $config->get('enabled_entity_types')) {
         $this->entityFieldManager->clearCachedFieldDefinitions();
         $this->aliasTypeManager->clearCachedDefinitions();
     }
     parent::submitForm($form, $form_state);
 }
Example #23
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove unnecessary values.
     $form_state->cleanValues();
     $pid = $form_state->getValue('pid', 0);
     $source = $form_state->getValue('source');
     $alias = $form_state->getValue('alias');
     // Language is only set if language.module is enabled, otherwise save for all
     // languages.
     $langcode = $form_state->getValue('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED);
     $this->aliasStorage->save($source, $alias, $langcode, $pid);
     drupal_set_message($this->t('The alias has been saved.'));
     $form_state->setRedirect('path.admin_overview');
 }
Example #24
0
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->cleanValues();

    /** @var \Drupal\linkit\MatcherInterface $plugin */
    $plugin = $this->manager->createInstance($form_state->getValue('plugin'));

    $plugin_uuid = $this->linkitProfile->addMatcher($plugin->getConfiguration());
    $this->linkitProfile->save();

    $this->logger('linkit')->notice('Added %label matcher to the @profile profile.', [
      '%label' => $this->linkitProfile->getMatcher($plugin_uuid)->getLabel(),
      '@profile' => $this->linkitProfile->label(),
    ]);

    $is_configurable = $plugin instanceof ConfigurableMatcherInterface;
    if ($is_configurable) {
      $form_state->setRedirect('linkit.matcher.edit', [
        'linkit_profile' => $this->linkitProfile->id(),
        'plugin_instance_id' => $plugin_uuid,
      ]);
    }
    else {
      drupal_set_message($this->t('Added %label matcher.', ['%label' => $plugin->getLabel()]));

      $form_state->setRedirect('linkit.matchers', [
        'linkit_profile' => $this->linkitProfile->id(),
      ]);
    }
  }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     $this->entity = $this->buildEntity($form, $form_state);
 }
	public function submitForm(array &$form, FormStateInterface $form_state) {

		// Remove Drupal stuff.
		$form_state->cleanValues();

		// Save values.
		foreach ($form_state->getValues() as $setting => $value) {

			$value = trim($value);

			// API Subdomain.
			if ($setting == 'api_subdomain') {
				// The subdomain is always in lower-case
				$value = strtolower($value);

				// Wrapper for full domains.
				if (preg_match("/([a-z0-9\-]+)\.api\.oneall\.com/i", $value, $matches)) {
					$value = trim($matches[1]);
				}
			}

			$oaslsid = db_select('oneall_social_login_settings', 'o')->fields('o', [
					'oaslsid'
					])->condition('setting', $setting, '=')->execute()->fetchField();
			if (is_numeric($oaslsid)) {
				db_update('oneall_social_login_settings')->fields(['value' => $value])->condition('oaslsid', $oaslsid, '=')->execute();
			}
			else {
				db_insert('oneall_social_login_settings')->fields([
						'setting' => $setting,
						'value' => $value,
						])->execute();
			}
		}
		drupal_set_message(t('Settings saved successfully'), 'status social_login');
		\Drupal::cache()->deleteAll();
		//\menu_rebuild();
	}
Example #27
0
 /**
  * {@inheritdoc}
  */
 public function cleanValues()
 {
     $this->mainFormState->cleanValues();
     return $this;
 }
Example #28
0
 /**
  * {@inheritdoc}
  */
 public function entityFormSubmit(array &$entity_form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     $entity = $entity_form['#entity'];
     $this->buildEntity($entity_form, $entity, $form_state);
 }
 /**
  * {@inheritdoc}
  *
  * This is the default entity object builder function. It is called before any
  * other submit handler to build the new entity object to be used by the
  * following submit handlers. At this point of the form workflow the entity is
  * validated and the form state can be updated, this way the subsequently
  * invoked handlers can retrieve a regular entity object to act on. Generally
  * this method should not be overridden unless the entity requires the same
  * preparation for two actions, see \Drupal\comment\CommentForm for an example
  * with the save and preview actions.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove button and internal Form API values from submitted values.
     $form_state->cleanValues();
     $this->entity = $this->buildEntity($form, $form_state);
 }
 /**
  *
  */
 protected function getConditionValues(FormStateInterface $form_state) {
   return $form_state->cleanValues()->getValue('conditions');
 }