public static function InsertFileWidgetUtility::validateClass in Insert 8
Cleans the class input removing any redundant whitespace.
Parameters
array $element:
\Drupal\Core\Form\FormState $form_state:
File
- src/
Utility/ InsertFileWidgetUtility.php, line 126
Class
Namespace
Drupal\insert\UtilityCode
public static function validateClass($element, &$form_state) {
$trimmedClasses = [];
foreach (explode(' ', $element['#value']) as $class) {
$class = trim($class);
if ($class !== '') {
$trimmedClasses[] = $class;
}
}
$form_state
->setValueForElement($element, join(' ', $trimmedClasses));
}