public static function YamlFormOptionsHelper::hasOption in YAML Form 8
Determine if the options has a specified value..
Parameters
string $value: An value to look for in the options.
array $options: An associative array of options.
Return value
bool TRUE if the options has a specified value.
2 calls to YamlFormOptionsHelper::hasOption()
- YamlFormOptionsHelperTest::testHasOption in tests/
src/ Unit/ YamlFormOptionsHelperTest.php - Tests YamlFormOptionsHelper::hasOption().
- YamlFormOtherBase::valueCallback in src/
Element/ YamlFormOtherBase.php - Determines how user input is mapped to an element's #value property.
File
- src/
Utility/ YamlFormOptionsHelper.php, line 21
Class
- YamlFormOptionsHelper
- Helper class form options based methods.
Namespace
Drupal\yamlform\UtilityCode
public static function hasOption($value, array $options) {
foreach ($options as $option_value => $option_text) {
if (is_array($option_text)) {
if ($has_value = self::hasOption($value, $option_text)) {
return $has_value;
}
}
elseif ($value == $option_value) {
return TRUE;
}
}
return FALSE;
}