public static function YamlFormLikert::processYamlFormLikertAnswers in YAML Form 8
Get likert element's answer which can include an N/A option.
Parameters
array $element: The element.
2 calls to YamlFormLikert::processYamlFormLikertAnswers()
- YamlFormLikert::initialize in src/
Plugin/ YamlFormElement/ YamlFormLikert.php - Initialize an element to be displayed, rendered, or exported.
- YamlFormLikert::processYamlFormLikert in src/
Element/ YamlFormLikert.php - Processes a likert scale form element.
File
- src/
Element/ YamlFormLikert.php, line 114
Class
- YamlFormLikert
- Provides a form element for a likert scale.
Namespace
Drupal\yamlform\ElementCode
public static function processYamlFormLikertAnswers(array &$element) {
if (empty($element['#na_answer']) || empty($element['#answers'])) {
return;
}
$na_value = !empty($element['#na_answer_value']) ? $element['#na_answer_value'] : (string) t('N/A');
$na_text = !empty($element['#na_answer_text']) ? $element['#na_answer_text'] : $na_value;
$element['#answers'] += [
$na_value => $na_text,
];
}