/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getValue('threshold')) { $form_state->setRedirect('uc_stock.threshold'); } else { $form_state->setRedirect('uc_stock.settings'); } }
/** * {@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) { $result = $form_state->getValue('fav_sock'); drupal_set_message($this->t('Your favorite sock is @fav_sock', array('@fav_sock' => $result))); if ($result == 'Ankle Biters') { $form_state->setRedirect('socks.knee_highs_controller_content'); } else { if ($result == 'Old Fashions') { $form_state->setRedirect('socks.old_fashions_controller_content'); } else { $form_state->setRedirect('socks.knee_highs_controller_content'); } } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $alphabets = $form_state->getValue('alphabet'); $output = $this->morseConvertToMorse($alphabets); drupal_set_message($this->t($output)); $form_state->setRedirect('morse.morse'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $list = $form_state->get('list'); $webhook_actions = $form_state->getValue('webhook_actions'); $actions = array(); foreach ($webhook_actions as $webhook_id => $enable) { $actions[$webhook_id] = $enable === 1; } $result = FALSE; if (count($actions) > 0) { $webhook_url = mailchimp_webhook_url(); $webhooks = mailchimp_webhook_get($list['id']); if (!empty($webhooks)) { foreach ($webhooks as $webhook) { if ($webhook['url'] == $webhook_url) { // Delete current webhook. mailchimp_webhook_delete($list['id'], mailchimp_webhook_url()); } } } // Add webhook with enabled actions. $result = mailchimp_webhook_add($list['id'], mailchimp_webhook_url(), $actions); } if ($result) { drupal_set_message(t('Webhooks for list "%name" have been updated.', array('%name' => $list['name']))); } else { drupal_set_message(t('Unable to update webhooks for list "%name".', array('%name' => $list['name'])), 'warning'); } $form_state->setRedirect('mailchimp_lists.overview'); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); $form_state->setRedirect('entity.' . $this->entity->getEntityTypeId() . '.canonical', array($this->entity->getEntityTypeId() => $this->entity->id())); $entity = $this->getEntity(); $entity->save(); }
/** * {@inheritdoc} */ public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label()))); $this->logger('block_content')->notice('Custom block %label has been deleted.', array('%label' => $this->entity->label())); $form_state->setRedirect('block_content.list'); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); drupal_set_message($this->t('Saved the %label store type.', [ '%label' => $this->entity->label(), ])); $form_state->setRedirect('entity.commerce_store_type.collection'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message(t('Newsletter %label has been deleted.', array('%label' => $this->entity->label()))); \Drupal::logger('simplenews')->notice('Newsletter %label has been deleted.', array('%label' => $this->entity->label())); $form_state->setRedirect('simplenews.newsletter_list'); }
/** * {@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'); }
/** * */ public function submitForm(array &$form, FormStateInterface $form_state) { ini_set('max_execution_time', $this->max_execution); $count = $this->deleteAllUsers(); drupal_set_message($this->t('All users have been deleted. Number of users deleted: !count.', array('!count' => String::checkPlain($count)))); $form_state->setRedirect('user.admin_account'); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $entity = $this->getEntity(); $redirect = $entity->getEntityType()->get('id'); $form_state->setRedirect('entity.' . $redirect . '.collection'); $entity->save(); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { XmlSitemapLinkStorage::linkDelete('custom', $this->custom_link['id']); drupal_set_message(t('The custom link for %loc has been deleted.', array('%loc' => $this->custom_link['loc']))); watchdog('xmlsitemap', 'The custom link for %loc has been deleted.', array('%loc' => $this->custom_link['loc']), WATCHDOG_NOTICE); $form_state->setRedirect('xmlsitemap_custom.list'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Redirect to the "Clear server" confirmation form. /** @var \Drupal\search_api\ServerInterface $server */ $server = $form['#server']; $form_state->setRedirect('entity.search_api_server.clear', array('search_api_server' => $server->id())); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->getEntity()->delete(); $this->logger->info('Payment #@payment_id has been deleted.', ['@payment_id' => $this->getEntity()->id()]); drupal_set_message($this->t('Payment #@payment_id has been deleted.', array('@payment_id' => $this->getEntity()->id()))); $form_state->setRedirect('<front>'); }
/** * {@inheritdoc} */ public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); $this->logger('aggregator')->notice('Feed %feed deleted.', array('%feed' => $this->entity->label())); drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label()))); $form_state->setRedirect('aggregator.sources'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->entity->disable(); $this->entity->save(); drupal_set_message($this->t('Captcha point %label has been disabled.', array('%label' => $this->entity->label()))); $form_state->setRedirect('captcha_point.list'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $morsecode = $form_state->getValue('morse'); $output = $this->morseConvertToAlpha($morsecode); drupal_set_message($this->t($output)); $form_state->setRedirect('morse.alpha'); }
/** * {@inheritdoc} * * Delete the entity and log the event. log() replaces the watchdog. */ public function submitForm(array &$form, FormStateInterface $form_state) { $entity = $this->getEntity(); $entity->delete(); \Drupal::logger('reservations')->notice('@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label())); $form_state->setRedirect('entity.reservation.list'); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { /** @var \Drupal\rdf_entity\Entity\Rdf $entity */ $entity = $this->getEntity(); $entity->save(); $form_state->setRedirect('entity.rdf_entity.canonical', ['rdf_entity' => $entity->id()]); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { /** @var \Drupal\search_api\ServerInterface $server */ $server = $this->getEntity(); try { $server->deleteAllItems(); drupal_set_message($this->t('All indexed data was successfully deleted from the server.')); } catch (SearchApiException $e) { drupal_set_message($this->t('Indexed data could not be cleared for some indexes. Check the logs for details.'), 'error'); } $failed_reindexing = array(); $properties = array('status' => TRUE, 'read_only' => FALSE); foreach ($server->getIndexes($properties) as $index) { try { $index->reindex(); } catch (SearchApiException $e) { $args = array('%index' => $index->label()); watchdog_exception('search_api', $e, '%type while clearing index %index: @message in %function (line %line of %file).', $args); $failed_reindexing[] = $index->label(); } } if ($failed_reindexing) { $args = array('@indexes' => implode(', ', $failed_reindexing)); drupal_set_message($this->t('Failed to mark the following indexes for reindexing: @indexes. Check the logs for details.', $args), 'warning'); } $form_state->setRedirect('entity.search_api_server.canonical', array('search_api_server' => $server->id())); }
/** * {@inheritdoc} * * Delete the entity and log the event. log() replaces the watchdog. */ public function submitForm(array &$form, FormStateInterface $form_state) { $entity = $this->getEntity(); $entity->delete(); \Drupal::logger('content_entity_example')->notice('@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label())); $form_state->setRedirect('entity.content_entity_example_contact.collection'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { uc_payment_enter($form_state->getValue('order_id'), 'check', $form_state->getValue('amount'), $this->currentUser()->id(), '', $form_state->getValue('comment')); db_insert('uc_payment_check')->fields(array('order_id' => $form_state->getValue('order_id'), 'clear_date' => mktime(12, 0, 0, $form_state->getValue('clear_month'), $form_state->getValue('clear_day'), $form_state->getValue('clear_year'))))->execute(); drupal_set_message($this->t('Check received, expected clear date of @date.', ['@date' => uc_date_format($form_state->getValue('clear_month'), $form_state->getValue('clear_day'), $form_state->getValue('clear_year'))])); $form_state->setRedirect('uc_order.admin_view', ['uc_order' => $form_state->getValue('order_id')]); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { batch_test_stack(NULL, TRUE); $function = '_batch_test_' . $form_state->getValue('batch'); batch_set($function()); $form_state->setRedirect('batch_test.redirect'); }
/** * Overrides Drupal\Core\Entity\EntityForm::delete(). */ public function delete(array $form, FormStateInterface $form_state) { $alias = $this->entity; // @TODO: error handling? $alias->delete(); $form_state->setRedirect('domain_alias.admin', array('domain' => $alias->getDomainID())); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $start_date = mktime(0, 0, 0, $form_state->getValue(['start_date', 'month']), $form_state->getValue(['start_date', 'day']), $form_state->getValue(['start_date', 'year'])); $end_date = mktime(23, 59, 59, $form_state->getValue(['end_date', 'month']), $form_state->getValue(['end_date', 'day']), $form_state->getValue(['end_date', 'year'])); $args = array('start_date' => $start_date, 'end_date' => $end_date, 'status' => implode(',', array_keys(array_filter($form_state->getValue('status'))))); $form_state->setRedirect('uc_report.custom.products', $args); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('language.negotiation'); $form['language_negotiation_session_param'] = array('#title' => $this->t('Request/session parameter'), '#type' => 'textfield', '#default_value' => $config->get('session.parameter'), '#description' => $this->t('Name of the request/session parameter used to determine the desired language.')); $form_state->setRedirect('language.negotiation'); return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { try { $entity = $this->entity; // Save as a new revision if requested to do so. if (!$form_state->isValueEmpty('revision')) { $entity->setNewRevision(); } $is_new = $entity->isNew(); $entity->save(); if ($is_new) { $message = t('%entity_type @id has been created.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId())); } else { $message = t('%entity_type @id has been updated.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId())); } drupal_set_message($message); if ($entity->id()) { $entity_type = $entity->getEntityTypeId(); $form_state->setRedirect("entity.{$entity_type}.edit_form", array($entity_type => $entity->id())); } else { // Error on save. drupal_set_message(t('The entity could not be saved.'), 'error'); $form_state->setRebuild(); } } catch (\Exception $e) { \Drupal::state()->set('entity_test.form.save.exception', get_class($e) . ': ' . $e->getMessage()); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->store->set('age', $form_state->getValue('age')); $this->store->set('location', $form_state->getValue('location')); // Save the data parent::saveData(); $form_state->setRedirect('some_route'); }
function submitForm(array &$form, FormStateInterface $form_state) { $result = ManageStorage::fetchRowFields('id', $this->id, array('fid')); file_delete($result['fid']); ManageStorage::delete($this->id); drupal_set_message('CSV deleted successfully.'); $form_state->setRedirect('node_csv_uploader.admin'); }