| @@ -280,8 +280,48 @@ | ||
| 280 | 280 | $bfMultipleFormsExists = $isPageBuilder ? true : count($bfUniqFormIds) > 1; |
| 281 | 281 | return $bfMultipleFormsExists; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | + /** | |
| 285 | + * Field keys the browser reported as hidden at submit time. | |
| 286 | + * | |
| 287 | + * Comma joined, and must be compared key by key: a substring test lets a hidden `b1-175` | |
| 288 | + * also match `b1-17`. | |
| 289 | + * | |
| 290 | + * @param mixed $rawHiddenFields the posted `hidden_fields` value (string or array) | |
| 291 | + * | |
| 292 | + * @return string[] | |
| 293 | + */ | |
| 294 | + public static function parseHiddenFieldKeys($rawHiddenFields) | |
| 295 | + { | |
| 296 | + if (is_array($rawHiddenFields)) { | |
| 297 | + $keys = $rawHiddenFields; | |
| 298 | + } elseif (is_string($rawHiddenFields)) { | |
| 299 | + $keys = explode(',', $rawHiddenFields); | |
| 300 | + } else { | |
| 301 | + return []; | |
| 302 | + } | |
| 303 | + | |
| 304 | + $keys = array_map(function ($key) { | |
| 305 | + return is_string($key) || is_numeric($key) ? trim((string) $key) : ''; | |
| 306 | + }, $keys); | |
| 307 | + | |
| 308 | + return array_values(array_unique(array_filter($keys, function ($key) { | |
| 309 | + return '' !== $key; | |
| 310 | + }))); | |
| 311 | + } | |
| 312 | + | |
| 313 | + /** | |
| 314 | + * @param mixed $hiddenFieldKeys parsed key list; anything else is treated as "nothing hidden" | |
| 315 | + * @param string $fieldKey | |
| 316 | + * | |
| 317 | + * @return bool | |
| 318 | + */ | |
| 319 | + public static function isFieldHidden($hiddenFieldKeys, $fieldKey) | |
| 320 | + { | |
| 321 | + return is_array($hiddenFieldKeys) && in_array($fieldKey, $hiddenFieldKeys, true); | |
| 322 | + } | |
| 323 | + | |
| 284 | 324 | public static function getFormPermissions($formId) |
| 285 | 325 | { |
| 286 | 326 | if (!isset(self::$formsPermissions[$formId])) { |
| 287 | 327 | $formManager = FormManager::getInstance($formId); |