Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,11 @@ public function onFormProcessed(Event $event)
$action = $event['action'];
$params = $event['params'];

$this->process($form);

switch ($action) {
case 'process':
$this->process($form);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears with your change, the form will only be processed IF it has a:

process:
  process: true
  ...

This would mean that all existing forms would no longer automatically process the fields.. Granted we currently only support the fillWithCurrentDateTime task, but still, it would not work until the form blueprint was updated.

break;

case 'captcha':

$captcha_config = $this->config->get('plugins.form.recaptcha');
Expand Down Expand Up @@ -857,6 +859,14 @@ protected function process($form)
if (!empty($field['process']['fillWithCurrentDateTime'])) {
$form->setData($field['name'], gmdate('D, d M Y H:i:s', time()));
}
if (!empty($field['process']['twig'])) {
$twig = $this->grav['twig'];
$vars = [
'form' => $form
];
// Process with Twig
$form->setData($field['name'], $twig->processString($field['process']['twig'], $vars));
}
}
}

Expand Down