function IconExtractorSettingsForm::buildStringForm
Build Drupal form for a string setting to a textfield.
Parameters
string $setting_id: The setting id from the icon pack definition.
array $setting: The settings from the icon pack definition.
array $saved_values: The default saved values if any.
Return value
array The form API generated for enum as textfield.
File
-
core/
lib/ Drupal/ Core/ Theme/ Icon/ IconExtractorSettingsForm.php, line 200
Class
- IconExtractorSettingsForm
- Handle icon extractor settings form conversion from YAML to Drupal Form API.
Namespace
Drupal\Core\Theme\IconCode
protected static function buildStringForm(string $setting_id, array $setting, array $saved_values) : array {
$form = self::initSettingForm($setting_id, $setting, $saved_values);
if (isset($setting['format']) && $setting['format'] === self::COLOR_TYPE) {
$form['#type'] = self::COLOR_TYPE;
return $form;
}
$form['#type'] = 'textfield';
if (isset($setting['pattern']) && !empty($setting['pattern'])) {
$form['#pattern'] = $setting['pattern'];
}
if (isset($setting['maxLength'])) {
$form['#maxlength'] = $setting['maxLength'];
}
// We don't support minLength and pattern together because it is not
// possible to safely merge regular expressions.
if (!isset($setting['pattern']) && isset($setting['minLength'])) {
$form['#pattern'] = '^.{' . $setting['minLength'] . ',}$';
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.