public function YamlFormLikert::getTestValue in YAML Form 8
Get test value for an element.
Parameters
array $element: An element.
\Drupal\yamlform\YamlFormInterface $yamlform: A form.
Return value
mixed A test value for an element.
Overrides YamlFormElementBase::getTestValue
File
- src/
Plugin/ YamlFormElement/ YamlFormLikert.php, line 310
Class
- YamlFormLikert
- Provides a 'likert' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function getTestValue(array $element, YamlFormInterface $yamlform) {
$value = [];
foreach ($element['#questions'] as $key => $question) {
$keys = array_keys($element['#answers']);
$value[$key] = $keys[array_rand($keys)];
}
return [
$value,
];
}