Page 1 of 1

For Form Builder, how do I get value of form_id in UDT

Posted: Thu Feb 14, 2013 7:34 pm
by RHF
This is very basic stuff, but I cannot seem to get the value of the Form Builder Smarty variable form_id in my UDT.
I have seen a couple of references that use something like
$gCms = cmsms();
$formid = $params['form_id '];
but this is not working for me. (The form field values are accessible through the $params array.)

I also tried accessing it through
$smarty = $gCms->GetSmarty();
$formid = $smarty->get_template_vars('form_id');
again with no luck.
I am sure this is very simple, but I have not yet been able to figure it out and would appreciate some help.
Thanks,
Bob

Re: For Form Builder, how do I get value of form_id in UDT

Posted: Wed Feb 20, 2013 5:07 pm
by rotezecke
assuming that {get_template_vars} shows form_id then this should work:

{yourUDT form_id_to_be_parsed=$form_id}

and your UDT processes it with
$formid = $params['form_id_to_be_parsed'];

also:
$smarty = $gCms->GetSmarty();
should be:
$smarty = cmsms()->GetSmarty();

Re: For Form Builder, how do I get value of form_id in UDT

Posted: Wed Feb 20, 2013 5:42 pm
by RHF
Thanks rotezecke,
Unfortunately, {get_template_vars} does not show form_id directly.
It turns out that it is located in the 'actionparams' Array in get_template_vars. So, you can get it with the following:

Code: Select all

$actparams = $smarty->get_template_vars('actionparams');
$form_id = $actparams['form_id'];
This was not obvious to me and I thought there must be a more direct way of getting the smarty variables described in the FormBuilder Help.