/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $form_values = $form_state->getValues(); $field_values = $form_values['field_storage']; // Save field cardinality. $cardinality = $field_values['cardinality']; $cardinality_number = $field_values['cardinality_number']; if ($cardinality === 'number') { $cardinality = $cardinality_number; } $field_values['cardinality'] = $cardinality; unset($field_values['container']); // Merge incoming form values into the existing field. $field_storage = $this->field->getFieldStorageDefinition(); foreach ($field_values as $key => $value) { $field_storage->set($key, $value); } // Update the field. try { $field_storage->save(); drupal_set_message($this->t('Updated field %label field settings.', array('%label' => $this->field->label()))); $request = $this->getRequest(); if (($destinations = $request->query->get('destinations')) && ($next_destination = FieldUI::getNextDestination($destinations))) { $request->query->remove('destinations'); $form_state->setRedirectUrl($next_destination); } else { $form_state->setRedirectUrl(FieldUI::getOverviewRouteInfo($this->field->entity_type, $this->field->bundle)); } } catch (\Exception $e) { drupal_set_message($this->t('Attempt to update field %label failed: %message.', array('%label' => $this->field->label(), '%message' => $e->getMessage())), 'error'); } }
/** * The _title_callback for the field settings form. * * @param \Drupal\field\FieldConfigInterface $field_config * The field. * * @return string * The label of the field. */ public function getTitle(FieldConfigInterface $field_config) { return SafeMarkup::checkPlain($field_config->label()); }
/** * The _title_callback for the field settings form. * * @param \Drupal\field\FieldConfigInterface $field_config * The field. * * @return string * The label of the field. */ public function getTitle(FieldConfigInterface $field_config) { return $field_config->label(); }