/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Remove unnecessary values. form_state_values_clean($form_state); $this->config('faq.settings')->set('title', $form_state['values']['faq_title'])->set('description', $form_state['values']['faq_description'])->set('custom_breadcrumbs', $form_state['values']['faq_custom_breadcrumbs'])->save(); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Remove unnecessary values. form_state_values_clean($form_state); $this->config('faq.settings')->set('display', $form_state['values']['faq_display'])->set('question_listing', $form_state['values']['faq_question_listing'])->set('qa_mark', $form_state['values']['faq_qa_mark'])->set('question_label', $form_state['values']['faq_question_label'])->set('answer_label', $form_state['values']['faq_answer_label'])->set('question_length', $form_state['values']['faq_question_length'])->set('question_long_form', $form_state['values']['faq_question_long_form'])->set('hide_qa_accordion', $form_state['values']['faq_hide_qa_accordion'])->set('show_expand_all', $form_state['values']['faq_show_expand_all'])->set('use_teaser', $form_state['values']['faq_use_teaser'])->set('back_to_top', $form_state['values']['faq_back_to_top'])->set('disable_node_links', $form_state['values']['faq_disable_node_links'])->set('default_sorting', $form_state['values']['faq_default_sorting'])->save(); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Remove unnecessary values. form_state_values_clean($form_state); $this->config('faq.settings')->set('use_categories', $form_state['values']['faq_use_categories'])->set('category_display', $form_state['values']['faq_category_display'])->set('category_listing', $form_state['values']['faq_category_listing'])->set('category_hide_qa_accordion', $form_state['values']['faq_category_hide_qa_accordion'])->set('count', $form_state['values']['faq_count'])->set('answer_category_name', $form_state['values']['faq_answer_category_name'])->set('group_questions_top', $form_state['values']['faq_group_questions_top'])->set('hide_child_terms', $form_state['values']['faq_hide_child_terms'])->set('show_term_page_children', $form_state['values']['faq_show_term_page_children'])->set('omit_vocabulary', $form_state['values']['faq_omit_vocabulary'])->save(); parent::submitForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { form_state_values_clean($form_state); // 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['values']); exit; }
/** * Overrides Drupal\Core\Entity\EntityForm::submit(). */ public function submit(array $form, FormStateInterface $form_state) { $admin = $form_state['values']['administer_users']; if (!\Drupal::config('user.settings')->get('verify_mail') || $admin) { $pass = $form_state['values']['pass']; } else { $pass = user_password(); } // Remove unneeded values. form_state_values_clean($form_state); $form_state['values']['pass'] = $pass; $form_state['values']['init'] = $form_state['values']['mail']; parent::submit($form, $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 passed to 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. * * @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 submit(array $form, FormStateInterface $form_state) { // Remove button and internal Form API values from submitted values. form_state_values_clean($form_state); $this->entity = $this->buildEntity($form, $form_state); return $this->entity; }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { // Remove unnecessary values. form_state_values_clean($form_state); $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; $source =& $form_state['values']['source']; $source = $this->aliasManager->getPathByAlias($source); $alias = $form_state['values']['alias']; // Language is only set if language.module is enabled, otherwise save for all // languages. $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LanguageInterface::LANGCODE_NOT_SPECIFIED; $this->aliasStorage->save($source, $alias, $langcode, $pid); drupal_set_message($this->t('The alias has been saved.')); $form_state['redirect_route'] = new Url('path.admin_overview'); }
/** * {@inheritdoc} */ public function submitEditForm(array &$form, array &$form_state) { // Remove button and internal Form API values from submitted values. form_state_values_clean($form_state); $this->entity = $this->buildEntity($form, $form_state); $this->entity->save(); return $form_state; }
function theme967_form_system_theme_settings_reset($form, &$form_state) { form_state_values_clean($form_state); variable_del('theme_theme967_settings'); $fp = fopen(drupal_get_path('theme', 'theme967') . '/css/custom.css', 'a'); ftruncate($fp, 0); fclose($fp); drupal_set_message(t('The configuration options have been reset to their default values.')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { form_state_values_clean($form_state); // The image effect configuration is stored in the 'data' key in the form, // pass that through for submission. $effect_data = new FormState(array('values' => $form_state['values']['data'])); $this->imageEffect->submitConfigurationForm($form, $effect_data); // Update the original form values. $form_state['values']['data'] = $effect_data['values']; $this->imageEffect->setWeight($form_state['values']['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')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { form_state_values_clean($form_state); print t('You WIN!'); exit; }
/** * Final submit handler. * * Reports what values were finally set. */ function md_leaders_save_settings_submit($form, &$form_state) { // Exclude unnecessary elements before saving. form_state_values_clean($form_state); $values = $form_state['values']; // Extract the name of the theme from the submitted form values, then remove // it from the array so that it is not saved as part of the variable. $theme_key = $values['var']; unset($values['var']); $form_input = $form_state['input']; // $form_state['values']['hd_image_slide'] = array(); // $form_state['values']['hd_ct'] = array(); $form_state['values']['highlights_info'] = array(); $form_state['values']['hd_ico'] = array(); $form_state['values']['ft_social'] = array(); $form_state['values']['contact_info'] = array(); foreach ($form_state['input'] as $key => $value) { //Header Social $hdsocial_info_match = "/hdsocial_info_order/i"; if (preg_match($hdsocial_info_match, $key)) { $explode = explode("|", $value); foreach ($explode as $key2 => $value2) { $new_key = str_replace("-", "_", $value2); $new_explode = explode("_", $new_key); end($new_explode); $number = current($new_explode); if ($new_key != null) { $icon_input = $form_input['hdsocial_info_icon_' . $number]['icon']; if ($icon_input != null) { $ft_sc_icon_explode = explode("|", $icon_input); $form_state['values']['hdsocial_info'][$new_key]['icon']['bundle'] = $ft_sc_icon_explode[0]; $form_state['values']['hdsocial_info'][$new_key]['icon']['icon'] = $ft_sc_icon_explode[1]; } $form_state['values']['hdsocial_info'][$new_key]['detail'] = $form_input['hdsocial_info_detail_' . $number] ? $form_input['hdsocial_info_detail_' . $number] : ''; } } } //highlights Detail $highlights_info_match = "/highlights_info_order/i"; if (preg_match($highlights_info_match, $key)) { $explode = explode("|", $value); foreach ($explode as $key2 => $value2) { $new_key = str_replace("-", "_", $value2); $new_explode = explode("_", $new_key); end($new_explode); $number = current($new_explode); if ($new_key != null) { $form_state['values']['highlights_info'][$new_key]['detail'] = $form_input['highlights_info_detail_' . $number] ? $form_input['highlights_info_detail_' . $number] : ''; } } } //Header panel ico $hd_ico_match = "/hd_ico_order/i"; if (preg_match($hd_ico_match, $key)) { $explode = explode("|", $value); foreach ($explode as $key2 => $value2) { $new_key = str_replace("-", "_", $value2); $new_explode = explode("_", $new_key); end($new_explode); $number = current($new_explode); if ($new_key != null) { $icon_input = $form_input['hd_ico_icon_' . $number]['icon']; if ($icon_input != null) { $ft_sc_icon_explode = explode("|", $icon_input); $form_state['values']['hd_ico'][$new_key]['icon']['bundle'] = $ft_sc_icon_explode[0]; $form_state['values']['hd_ico'][$new_key]['icon']['icon'] = $ft_sc_icon_explode[1]; } $form_state['values']['hd_ico'][$new_key]['panel_href'] = $form_input['hd_ico_panel_href_' . $number] ? $form_input['hd_ico_panel_href_' . $number] : ''; $form_state['values']['hd_ico'][$new_key]['panel_detail'] = $form_input['hd_ico_panel_detail_' . $number] ? $form_input['hd_ico_panel_detail_' . $number] : ''; } } } //Footer Social $ft_social_match = "/ft_social_order/i"; if (preg_match($ft_social_match, $key)) { $explode = explode("|", $value); foreach ($explode as $key2 => $value2) { $new_key = str_replace("-", "_", $value2); $new_explode = explode("_", $new_key); end($new_explode); $number = current($new_explode); if ($new_key != null) { $icon_input = $form_input['ft_social_icon_' . $number]['icon']; if ($icon_input != null) { $ft_sc_icon_explode = explode("|", $icon_input); $form_state['values']['ft_social'][$new_key]['icon']['bundle'] = $ft_sc_icon_explode[0]; $form_state['values']['ft_social'][$new_key]['icon']['icon'] = $ft_sc_icon_explode[1]; } $form_state['values']['ft_social'][$new_key]['link'] = $form_input['ft_social_link_' . $number] ? $form_input['ft_social_link_' . $number] : ''; } } } //Contact Detail $contact_info_match = "/contact_info_order/i"; if (preg_match($contact_info_match, $key)) { $explode = explode("|", $value); foreach ($explode as $key2 => $value2) { $new_key = str_replace("-", "_", $value2); $new_explode = explode("_", $new_key); end($new_explode); $number = current($new_explode); if ($new_key != null) { $icon_input = $form_input['contact_info_icon_' . $number]['icon']; if ($icon_input != null) { $contact_info_icon_explode = explode("|", $icon_input); $form_state['values']['contact_info'][$new_key]['icon']['bundle'] = $contact_info_icon_explode[0]; $form_state['values']['contact_info'][$new_key]['icon']['icon'] = $contact_info_icon_explode[1]; } $form_state['values']['contact_info'][$new_key]['detail'] = $form_input['contact_info_detail_' . $number] ? $form_input['contact_info_detail_' . $number] : ''; } } } } $form_state['#rebuild'] = true; cache_clear_all(); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $config = $this->config($form_state['values']['config_key']); // Exclude unnecessary elements before saving. form_state_values_clean($form_state); unset($form_state['values']['var']); unset($form_state['values']['config_key']); $values = $form_state['values']; // If the user uploaded a new logo or favicon, save it to a permanent location // and use it in place of the default theme-provided file. if ($this->moduleHandler->moduleExists('file')) { if ($file = $values['logo_upload']) { unset($values['logo_upload']); $filename = file_unmanaged_copy($file->getFileUri()); $values['default_logo'] = 0; $values['logo_path'] = $filename; $values['toggle_logo'] = 1; } if ($file = $values['favicon_upload']) { unset($values['favicon_upload']); $filename = file_unmanaged_copy($file->getFileUri()); $values['default_favicon'] = 0; $values['favicon_path'] = $filename; $values['toggle_favicon'] = 1; } // If the user entered a path relative to the system files directory for // a logo or favicon, store a public:// URI so the theme system can handle it. if (!empty($values['logo_path'])) { $values['logo_path'] = $this->validatePath($values['logo_path']); } if (!empty($values['favicon_path'])) { $values['favicon_path'] = $this->validatePath($values['favicon_path']); } if (empty($values['default_favicon']) && !empty($values['favicon_path'])) { $values['favicon_mimetype'] = file_get_mimetype($values['favicon_path']); } } theme_settings_convert_to_config($values, $config)->save(); // Invalidate either the theme-specific cache tag or the global theme // settings cache tag, depending on whose settings were actually changed. if (isset($values['theme'])) { Cache::invalidateTags(array('theme' => $values['theme'])); } else { Cache::invalidateTags(array('theme_global_settings' => TRUE)); } }