class YamlFormHelper in YAML Form 8
Helper class form based methods.
Hierarchy
- class \Drupal\yamlform\Utility\YamlFormHelper
Expanded class hierarchy of YamlFormHelper
1 file declares its use of YamlFormHelper
- YamlFormHelperTest.php in tests/
src/ Unit/ YamlFormHelperTest.php
File
- src/
Utility/ YamlFormHelper.php, line 8
Namespace
Drupal\yamlform\UtilityView source
class YamlFormHelper {
/**
* Cleanup form state values.
*
* @param array $values
* An array of form state values.
* @param array $keys
* (optional) An array of custom keys to be removed.
*
* @return array
* The values without default keys like
* 'form_build_id', 'form_token', 'form_id', 'op', 'actions', etc...
*/
public static function cleanupFormStateValues(array $values, array $keys = []) {
// Remove default FAPI values.
unset($values['form_build_id'], $values['form_token'], $values['form_id'], $values['op']);
// Remove any objects.
foreach ($values as $key => $value) {
if (is_object($value)) {
unset($values[$key]);
}
}
// Remove custom keys.
foreach ($keys as $key) {
unset($values[$key]);
}
return $values;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
YamlFormHelper:: |
public static | function | Cleanup form state values. |