Elgg  Version master
PrepareFields.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Forms;
4 
11 
19  public function __invoke(\Elgg\Event $event): ?array {
20  if (!(bool) $event->getParam('sticky_enabled')) {
21  return null;
22  }
23 
24  $form_name = $event->getParam('sticky_form_name');
25  if (empty($form_name) || !elgg_is_sticky_form($form_name)) {
26  return null;
27  }
28 
29  $ignored_fields = (array) $event->getParam('sticky_ignored_fields');
30  $body_vars = $event->getValue();
31 
32  // merge the sticky values into the fields
33  $sticky_vars = elgg_get_sticky_values($form_name);
34  foreach ($sticky_vars as $key => $value) {
35  if (in_array($key, $ignored_fields)) {
36  // this shouldn't happen, but just in case
37  continue;
38  }
39 
41  }
42 
43  // clear the sticky values
44  elgg_clear_sticky_form($form_name);
45 
46  return $body_vars;
47  }
48 }
elgg_clear_sticky_form(string $form_name)
Remove form submission data from the session.
Definition: input.php:121
__invoke(\Elgg\Event $event)
Generic sticky form fields handler.
$value
Definition: generic.php:51
Prepare sticky form fields.
elgg_get_sticky_values(string $form_name, bool $filter_result=true)
Get all submission data cached for a form.
Definition: input.php:161
$body_vars
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
elgg_is_sticky_form(string $form_name)
Does form submission data exist for this form?
Definition: input.php:133
Models an event passed to event handlers.
Definition: Event.php:11