diff --git a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php index 170b5a0..5ddc2b1 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php @@ -25,18 +25,18 @@ public function form(array $form, array &$form_state, EntityInterface $category) '#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, - '#default_value' => $category->label(), + '#default_value' => $category->label, '#description' => t("Example: 'website feedback' or 'product information'."), '#required' => TRUE, ); $form['id'] = array( '#type' => 'machine_name', - '#default_value' => $category->id(), + '#default_value' => $category->id, '#machine_name' => array( 'exists' => 'contact_category_load', 'source' => array('label'), ), - '#disabled' => (bool) $category->id(), + '#disabled' => !$category->isNew(), ); $form['recipients'] = array( '#type' => 'textarea', @@ -110,6 +110,7 @@ public function submit(array $form, array &$form_state) { public function save(array $form, array &$form_state) { $category = $this->getEntity($form_state); $category->save(); + $id = $form_state['values']['id']; drupal_set_message(t('Category %label has been saved.', array('%label' => $category->label()))); watchdog('contact', 'Category %label has been saved.', array('%label' => $category->label()), WATCHDOG_NOTICE, l(t('Edit'), 'admin/structure/contact/manage/' . $category->id())); @@ -118,11 +119,11 @@ public function save(array $form, array &$form_state) { $contact_config = config('contact.settings'); if ($form_state['values']['selected']) { $contact_config - ->set('default_category', $form_state['values']['id']) + ->set('default_category', $id) ->save(); } // If it was the default category, empty out the setting. - elseif ($contact_config->get('default_category') == $form_state['values']['id']) { + elseif ($contact_config->get('default_category') == $id) { $contact_config ->clear('default_category') ->save();