public static function WebformFormHelper::cleanupFormStateValues in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformFormHelper.php \Drupal\webform\Utility\WebformFormHelper::cleanupFormStateValues()
Cleanup webform state values.
Parameters
array $values: An array of webform state values.
array $keys: (optional) An array of custom keys to be removed.
Return value
array The values without default keys like 'form_build_id', 'form_token', 'form_id', 'op', 'actions', etc…
1 call to WebformFormHelper::cleanupFormStateValues()
- WebformFormHelperTest::testCleanupFormStateValues in tests/
src/ Unit/ Utility/ WebformFormHelperTest.php - Tests WebformFormHelper::cleanupFormStateValues().
File
- src/
Utility/ WebformFormHelper.php, line 167
Class
- WebformFormHelper
- Helper class webform based methods.
Namespace
Drupal\webform\UtilityCode
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;
}