/** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $values['default'] = (bool) $values['default']; $values['roles'] = array_values(array_filter($values['roles'])); $form_state->set('values', $values); parent::submitConfigurationForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $currency_locale = $this->configImporter->importCurrencyLocale($form_state->getValues()['locale']); drupal_set_message($this->t('The %label has been imported.', ['%label' => $currency_locale->label()])); if ($form_state->getTriggeringElement()['#name'] == 'import_edit') { $form_state->setRedirectUrl($currency_locale->urlInfo('edit-form')); } else { $form_state->setRedirectUrl(new Url('entity.currency_locale.collection')); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $auto_import = array(); foreach ($form_state->getValues()['auto_import'] as $file) { $auto_import[] = array('filename' => $file, 'hash' => ''); } $this->config(static::CONFIGNAME)->set('auto_import', $auto_import)->set('auto_export', $form_state->getValues()['auto_export'])->save(); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $this->setConfigurationValue('flickr_source', $form_state->getValues()['flickr_source']); $this->setConfigurationValue('flickr_userId', $form_state->getValues()['flickr_userId']); $this->setConfigurationValue('flickr_groupId', $form_state->getValues()['flickr_groupId']); $this->setConfigurationValue('flickr_setId', $form_state->getValues()['flickr_setId']); $this->setConfigurationValue('flickr_num_photo', $form_state->getValues()['flickr_num_photo']); $this->setConfigurationValue('flickr_display', $form_state->getValues()['flickr_display']); $this->setConfigurationValue('flickr_image_size', $form_state->getValues()['flickr_image_size']); $this->setConfigurationValue('flickr_layout', $form_state->getValues()['flickr_layout']); $this->setConfigurationValue('flickr_tag', $form_state->getValues()['flickr_tag']); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $form_values = $form_state->getValues(); $module = 'customer_contact'; $key = 'contact_message'; // Specify 'to' and 'from' addresses. $to = "*****@*****.**"; $from = \Drupal::config('system.site')->get('mail'); // Output $output = ''; $output .= 'First name: ' . $form_values['first_name'] . '\\n'; $output .= 'Last name: ' . $form_values['last_name'] . '\\n'; $output .= 'Company: ' . $form_values['company'] . '\\n'; $output .= 'Phone number: ' . $form_values['phone_number'] . '\\n'; $output .= 'Website: ' . $form_values['website'] . '\\n'; $output .= 'Know about: ' . $form_values['know_about'] . '\\n'; $output .= 'Project start: ' . $form_values['project_start'] . '\\n'; $output .= 'Price range: ' . $form_values['price_range'] . '\\n'; $output .= 'Description: ' . $form_values['description'] . '\\n'; $params = array('message' => $output); $language_code = \Drupal::languageManager()->getDefaultLanguage()->getId(); $send_now = TRUE; // Send the mail, and check for success. Note that this does not guarantee // message delivery; only that there were no PHP-related issues encountered // while sending. $result = $this->mailManager->mail($module, $key, $to, $language_code, $params, $from, $send_now); if ($result['result'] == TRUE) { drupal_set_message(t('An email has been sent to Create Inside. Thank your for your time.')); } else { drupal_set_message(t('There was a problem sending your message.'), 'error'); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $document = array('#type' => 'texgen_document', '#texgenformdata' => $form_state->getValues()); global $_SESSION; $_SESSION['texgen']['result'] = \Drupal::service('renderer')->render($document); $form_state->setRedirectUrl(Url::fromRoute('texgen.page')); }
/** * {@inheritdoc} */ public function validateExposed(&$form, FormStateInterface $form_state) { // Only validate exposed input. if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) { return; } // We only need to validate if there is a minimum word length set. if ($this->options['min_length'] < 2) { return; } $identifier = $this->options['expose']['identifier']; $input =& $form_state->getValues()[$identifier]; if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) { $this->operator = $this->options['group_info']['group_items'][$input]['operator']; $input =& $this->options['group_info']['group_items'][$input]['value']; } // If there is no input, we're fine. if (!trim($input)) { return; } $words = preg_split('/\\s+/', $input); foreach ($words as $i => $word) { if (Unicode::strlen($word) < $this->options['min_length']) { unset($words[$i]); } } if (!$words) { $vars['@count'] = $this->options['min_length']; $msg = $this->t('You must include at least one positive keyword with @count characters or more.', $vars); $form_state->setError($form[$identifier], $msg); } $input = implode(' ', $words); }
/** * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { $values =& $form_state->getValues(); $values['allowed_schemes'] = array_filter($values['allowed_schemes']); // Convert allowed_extensions to an array for storage. $values['allowed_extensions'] = array_unique(explode(' ', preg_replace('/\\s+/', ' ', trim($values['allowed_extensions'])))); }
public function submitForm(array &$form, FormStateInterface $form_state) { // Display result. foreach ($form_state->getValues() as $key => $value) { drupal_set_message($key . ': ' . $value); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $entry = array('gid' => $values['gid'], 'title' => $values['title'], 'description' => $values['description'], 'time_zone' => $values['time_zone'], 'parent_gid' => empty($values['parent_gid']) ? NULL : $values['parent_gid']); // If logo fid is changed, delete old and set new for permanent status. $logo_fid = isset($values['logo_fid'][0]) ? $values['logo_fid'][0] : NULL; $old_logo_fid = $values['old_logo_fid']; if (!empty($logo_fid) && $logo_fid != $old_logo_fid) { // Set old file for removal. $file = file_load($old_logo_fid); if ($file) { \Drupal::service('file.usage')->delete($file, 'ea_groupings', 'group', $values['gid']); } // Add file permanently. $file = file_load($logo_fid); if ($file) { $file->status = FILE_STATUS_PERMANENT; $file->save(); \Drupal::service('file.usage')->add($file, 'ea_groupings', 'group', $values['gid']); } // Add new fid to entry. $entry['logo_fid'] = $logo_fid; } // Save the submitted entry. $return = EAGroupingsStorage::update($entry); if ($return) { drupal_set_message(t('Updated @title', array('@title' => $entry['title']))); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // drupal_set_message($this->t('@can_name ,Your application is being submitted!', array('@can_name' => $form_state->getValue('candidate_name')))); foreach ($form_state->getValues() as $key => $value) { drupal_set_message($key . ': ' . $value); } }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $quote_config = $this->config('uc_quote.settings'); $address = $quote_config->get('store_default_address'); $form['uc_quote_display_debug'] = array('#type' => 'checkbox', '#title' => $this->t('Display debug information to administrators.'), '#default_value' => $quote_config->get('display_debug')); $form['uc_quote_require_quote'] = array('#type' => 'checkbox', '#title' => $this->t('Prevent the customer from completing an order if a shipping quote is not selected.'), '#default_value' => $quote_config->get('require_quote')); $form['default_address'] = array('#type' => 'details', '#title' => $this->t('Default pickup address'), '#description' => $this->t("When delivering products to customers, the original location of the product must be known in order to accurately quote the shipping cost and set up a delivery. This form provides the default location for all products in the store. If a product's individual pickup address is blank, Ubercart uses the store's default pickup address specified here.")); $form['default_address']['address'] = array('#type' => 'uc_address', '#default_value' => $form_state->getValues() ?: $address, '#required' => FALSE); $shipping_types = uc_quote_shipping_type_options(); if (is_array($shipping_types)) { $form['uc_quote_type_weight'] = array('#type' => 'details', '#title' => $this->t('List position'), '#description' => $this->t('Determines which shipping methods are quoted at checkout when products of different shipping types are ordered. Larger values take precedence.'), '#tree' => TRUE); $weight = $quote_config->get('type_weight'); $shipping_methods = \Drupal::moduleHandler()->invokeAll('uc_shipping_method'); $method_types = array(); foreach ($shipping_methods as $method) { // Get shipping method types from shipping methods that provide quotes if (isset($method['quote'])) { $method_types[$method['quote']['type']][] = $method['title']; } } if (isset($method_types['order']) && is_array($method_types['order'])) { $count = count($method_types['order']); $form['uc_quote_type_weight']['#description'] .= $this->formatPlural($count, '<br />The %list method is compatible with any shipping type.', '<br />The %list methods are compatible with any shipping type.', ['%list' => implode(', ', $method_types['order'])]); } foreach ($shipping_types as $id => $title) { $form['uc_quote_type_weight'][$id] = array('#type' => 'weight', '#title' => $title . (isset($method_types[$id]) && is_array($method_types[$id]) ? ' (' . implode(', ', $method_types[$id]) . ')' : ''), '#delta' => 5, '#default_value' => isset($weight[$id]) ? $weight[$id] : 0); } } $form['uc_store_shipping_type'] = array('#type' => 'select', '#title' => $this->t('Default order fulfillment type for products'), '#options' => $shipping_types, '#default_value' => $quote_config->get('shipping_type')); return parent::buildForm($form, $form_state); }
/** * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $config = $this->config('google_analytics_lite.settings'); $config->set('trackingId', $values['trackingId'])->save(); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $file = File::load($values['file'][0]); // Load File entity. $read_file = new \SplFileObject($file->url()); // Create file handler. $lines = 1; $in_queue = 0; $queue = \Drupal::queue('eventninja'); // Load queue while (!$read_file->eof()) { $data = $read_file->fgetcsv(';'); if ($lines > 1) { // skip headers $user = user_load_by_mail($data[1]); if ($user === false) { // Verify if user with specified email does not exist. $queue->createItem($data); $in_queue++; } else { $this->logger('eventninja')->log(RfcLogLevel::NOTICE, 'User {mail} hasn\'t been created.', ['mail' => $data[1]]); } } $lines++; } if ($lines > 1) { drupal_set_message($this->t('@num records was scheduled for import', array('@num' => $in_queue)), 'success'); } else { drupal_set_message($this->t('File contains only headers'), 'error'); } }
/** * {@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(); 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'); } }
/** * Override this function to let it store the config which would otherwise be * removed for some reason. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity the current form should operate upon. * @param array $form * A nested array of form elements comprising the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { $values = $form_state->getValues(); foreach ($values as $key => $value) { $entity->set($key, $value); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $config = \Drupal::configFactory()->getEditable('custom.Eventbrite'); $config->set('eventId', $values['eventid'])->save(); $config->set('appKey', $values['appkey'])->save(); $config->set('userKey', $values['userkey'])->save(); }
/** * {@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; }
/** * {@inheritdoc} */ public function validateConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) { $values = $form_state->getValues(); if (!empty($values['maximum_items']) && !empty($values['minimum_items']) && $values['maximum_items'] <= $values['minimum_items']) { $form_state->setErrorByName('maximum_items', t('If both minimum and maximum item count are specified, the maximum item count should be higher than the minimum item count.')); } return parent::validateConfigurationForm($form, $form_state, $facet); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->get('json')) { $form_state->setResponse(new JsonResponse($form_state->getValues())); } else { $form_state->disableRedirect(); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $files = array_filter($values['table']); foreach ($files as $file) { backup_db_history_delete($file); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->config('subpathauto.settings') ->set('depth', $values['depth']) ->save(); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); foreach ($values['existing_members'] as $pid) { // Save the submitted entry. $return = EAGroupingMembersStorage::insert(array('pid' => $pid, 'gid' => $values['gid'])); } drupal_set_message(t('Added members')); }
/** * {@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) { $values = $form_state->getValues(); $config = []; // Load the settings profile if one is selected. if ($values['settings_profile_id']) { $config = SettingsProfile::load($values['settings_profile_id'])->get('config'); } backup_migrate_perform_backup($values['source_id'], $values['destination_id'], $config); }
/** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $config = \Drupal::service('config.factory')->getEditable('follow.settings'); $values = $form_state->getValues(); $config->set('follow_user_block_title', $values['follow_title'])->save(); $config->set('follow_user_alignment', $values['follow_alignment'])->save(); $config->set('follow_user_icon_style', $values['follow_icon_style'])->save(); // Reset the CSS in case the styles changed. follow_save_css(TRUE); }
/** * {@inheritdoc} */ protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { /** @var \Drupal\currency\Entity\CurrencyLocaleInterface $currency_locale */ $currency_locale = $entity; $values = $form_state->getValues(); $currency_locale->setLocale($values['language_code'], $values['country_code']); $currency_locale->setPattern($values['pattern']); $currency_locale->setDecimalSeparator($values['decimal_separator']); $currency_locale->setGroupingSeparator($values['grouping_separator']); }
/** * {@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); }
/** * Implements submitForm callback. * * @inheritdoc */ public function submitForm(array &$form, FormStateInterface $form_state) { // Find out what was submitted. $values = $form_state->getValues(); if ($values['needs_accommodation']) { drupal_set_message($this->t('Dietary Restriction Requested: %diet', ['%diet' => $values['diet']])); } }