parseLanguagesFromValue example

$form['languages']['#default_value'] = $as_selectors;
    }

    return $form;
  }

  /** * {@inheritdoc} */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    $form_value = $form_state->getValue('languages');
    [$styles$unparseable_lines] = self::parseLanguagesFromValue($form_value);
    if (!empty($unparseable_lines)) {
      $line_numbers = array_keys($unparseable_lines);
      $form_state->setError($form['languages']$this->formatPlural(
        count($unparseable_lines),
        'Line @line-number does not contain a valid value. Enter a valid language key followed by a pipe symbol and a label.',
        'Lines @line-numbers do not contain a valid value. Enter a valid language key followed by a pipe symbol and a label.',
        [
          '@line-number' => reset($line_numbers),
          '@line-numbers' => implode(', ', $line_numbers),
        ]
      ));
    }
Home | Imprint | This part of the site doesn't use cookies.