How do I set redirectParams from a hook in FormIt, MODx revo?
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 h开发者_开发技巧ook (as is the case when there's new stuff being created), I can't set redirectParams
right, or can I?
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.
$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.
精彩评论