<![CDATA[ Formit/Formalicious redirectTo based off of context variable - My Forums]]> https://forums.modx.com/thread/?thread=103459 <![CDATA[Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable?page=2#dis-post-556632
&redirectTo=[[++membership_renewal_resource]]

it doesn't actually work. Is there a different way to achieve this?]]>
aarond Feb 01, 2018, 05:23 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable?page=2#dis-post-556632
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556650
I'm still baffled by why your code is necessary, but if it works, it works. Maybe it's the missing back-ticks:

&redirectTo=`[[++membership_renewal_resource]]`


]]>
BobRay Feb 01, 2018, 09:17 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556650
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556648 Quote from: BobRay at Feb 01, 2018, 09:04 PM
In that case, I think you want a postHook. Otherwise, the redirect may happen before the form is even displayed.

My pre-hook isn't telling the form to submit though, its just setting the variable for when the form is submitted. I have tested this and it works good. I think a postHook would run into the same issue, in that the formalicious GUI can't set the resourceID from a context variable during/after the form renders.]]>
aarond Feb 01, 2018, 09:07 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556648
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556647 BobRay Feb 01, 2018, 09:04 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556647 <![CDATA[Re: Formit/Formalicious redirectTo based off of context variable (Best Answer)]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556645
<?php
$redirectID = $modx->context->getOption('membership_renewal_resource', null, '1');
$formit->config['redirectTo'] = $redirectID;
return true;
]]>
aarond Feb 01, 2018, 08:54 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556645
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556643
I would think you'd want a hook, rather than a preHook.

The hook could look something like this, which gets the redirect ID directly from the Context Setting:

$id = (int) $modx->getOption('membership_renewal_resource');
$url = $modx->makeURL($id, 'web', "", 'full');
$modx->sendRedirect($url);
return;
]]>
BobRay Feb 01, 2018, 08:43 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556643
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556641 lkfranklin Feb 01, 2018, 08:35 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556641 <![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556639 Quote from: BobRay at Feb 01, 2018, 08:00 PM
If you're seeing the number in the source, it's definitely reading the context setting. Since it's just a number, I don't think it's a parsing issue.

I couldn't find any docs for the redirectTo property. I'm guessing it's not redirectTo. I'd look at the formalicious code in core/components/formalicious/elements, or more likely, core/components/formalicious/model to see the actual property name used in the getOption() call. It will be case-sensitive.

I'm not the greatest at coding. I think this issue could be solved with a custom pre-hook maybe. I am not 100% sure on the syntax, but would a custom prehook called, say, setRedirectID work with the following pseudocode?

Set $redirectTo [[++membership_renewal_resource]].

This way I think it would set the redirect to before it generates the form on the page, whereas right now, it might just be taking [[++membership_renewal_resource]] and putting that in as a string, rather than converting it to the ID in the context variable.]]>
aarond Feb 01, 2018, 08:09 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556639
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556638
I couldn't find any docs for the redirectTo property. I'm guessing it's not redirectTo. I'd look at the formalicious code in core/components/formalicious/elements, or more likely, core/components/formalicious/model to see the actual property name used in the getOption() call. It will be case-sensitive.]]>
BobRay Feb 01, 2018, 08:00 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556638
<![CDATA[Re: Formit/Formalicious redirectTo based off of context variable]]> https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556635 Quote from: lkfranklin at Feb 01, 2018, 07:23 PM
Have you tried calling it uncached? Verify it's posting the correct value by placing it in the body so you can see its output too.

I put the [[++membership_renewal_resource]] in an html content block on the page where my form is, so that it can be seen, and yes it is parsing the number properly. It seems as if the redirectTo parameter isn't parsing the context variable.]]>
aarond Feb 01, 2018, 07:39 PM https://forums.modx.com/thread/103459/formit-formalicious-redirectto-based-off-of-context-variable#dis-post-556635