You are here

protected function CustomLanguageForm::copyFormValuesToEntity in Custom Language field 8

Copies top-level form values to entity properties

This should not change existing entity properties that are not being edited by this form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.

array $form: A nested array of form elements comprising the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides EntityForm::copyFormValuesToEntity

File

src/Form/CustomLanguageForm.php, line 125

Class

CustomLanguageForm
Form controller for the CustomLanguage entity edit forms.

Namespace

Drupal\languagefield\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
  $langcode = trim($form_state
    ->getValue('langcode'));
  $label = trim($form_state
    ->getValue('label'));
  $direction = trim($form_state
    ->getValue('direction'));
  $native = trim($form_state
    ->getValue('native_name'));
  $entity
    ->set('id', $langcode);
  $entity
    ->set('label', $label);
  $entity
    ->set('native_name', $native);
  $entity
    ->set('direction', $direction);
}