public function HttpConfigRequestForm::arrayValue in HTTP Client Manager 8
Value callback: converts strings to array values.
See also
form
File
- src/
Form/ HttpConfigRequestForm.php, line 172
Class
- HttpConfigRequestForm
- Class HttpConfigRequestForm.
Namespace
Drupal\http_client_manager\FormCode
public function arrayValue(&$element, $input, FormStateInterface $form_state) {
if ($input !== FALSE && $input !== NULL) {
$input = trim($input);
if (empty($input)) {
return [];
}
$value_callback = $this
->getValueCallback($element['#command_param']);
$items = explode("\n", $input);
foreach ($items as &$item) {
$item = trim($item);
if ($value_callback) {
$item = $this
->{$value_callback}($element, $item, $form_state);
}
}
return $items;
}
return !empty($element['#default_value']) ? implode("\n", $element['#default_value']) : NULL;
}