0

How do I set redirectParams from a hook in FormIt, MODx revo? I need it in order to redirect the user to the view page after the edit with the correct ID of what was edited. The problem is: if ID wasn't known before the hook (as is the case when there's new stuff being created), I can't set redirectParams right, or can I?

curveball
  • 4,320
  • 15
  • 39
  • 49
Alexei Averchenko
  • 1,706
  • 1
  • 16
  • 29

2 Answers2

1

Ok, I worked around this limitation by introducing a hidden input with name 'id', setting it to the correct ID in a hook, and then redirecting to a FormItRetriever page, where I retrieve ID and redirect yet again.

Alexei Averchenko
  • 1,706
  • 1
  • 16
  • 29
0

$hook->formit->setOption( 'redirectParams', json_encode( [ 'param1' => 'value1', 'param2' => 'value2' ] ) );

Where $hook is the \Sterc\FormIt\Hook instance set by FormIt when running the hook snippet.

Bence Szalai
  • 768
  • 8
  • 20