Formbuilder and UDT (SOLVED)

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
davidaldred
New Member
New Member
Posts: 5
Joined: Sat Apr 13, 2013 7:35 pm

Formbuilder and UDT (SOLVED)

Post by davidaldred »

Hi

I'm using CMSMS 1.11.4 and Formbuilder 0.7.3; PHP version is 5.3.8 adn this is running on Linux/Apache.

I have a formbuilder form on a page, and when it is submitted I'd like to use a UDT to output something which depends on the value of a form field: simplifying a bit, I want to take an input number and turn it into a cost at £10 each - so if the field 'number' is '2', then I want to output '£20'.

I've set the submission template to include a UDT. At the moment, being very basic about it, all I'm trying to do is output any form value via a UDT. There is a form field called 'name', so to test that I can get that value in a UDT, so my UDT says:

Code: Select all

echo "Here it comes: ";
echo $name; 
echo "That was it";
When the form is submitted, all I get is
Here is comes: That was it.
I've tried things like $(params['name']) and one or two other possibilities, but the results don't change.

What do I need to put into the UDT to get the value of the form field, so that I can manipulate it?

I'm probably missing something obvious here...
Last edited by davidaldred on Tue Apr 16, 2013 2:27 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder and UDT

Post by Jo Morg »

Try

Code: Select all

$params['field_name']
... being field_name the name of the field... it's on the help of the module... also you don't say how are you calling the UDT.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
davidaldred
New Member
New Member
Posts: 5
Joined: Sat Apr 13, 2013 7:35 pm

Re: Formbuilder and UDT

Post by davidaldred »

Thanks for the suggestion. I've changed the UDT to say:

Code: Select all

echo $params['Name'];
..but the result is still the same.

The UDT is called ShowFormValues and is called in the form submission template:

Code: Select all

<h2>Thanks! Your submissions have been received.</h2>

{ShowFormValues}
and the form is set to display the submission template after submission.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder and UDT

Post by Jo Morg »

I believe you haven't read the whole help file, but still, lets try to understand your problem.
Have you created a field of the type: Call A User Defined Tag With the Form Results?
That's the way you link the results of a form to a UDT (you will have to select one on the drop-down on the field settings page). That way the UDT will be able to process the data through PHP.
Calling the UDT from a template or a page won't populate the $params array. That will be a separate logic. And, as we can't guess what you wan to do, it's a bit hard to help any further...
davidaldred wrote:I have a formbuilder form on a page, and when it is submitted I'd like to use a UDT to output something which depends on the value of a form field: simplifying a bit, I want to take an input number and turn it into a cost at £10 each - so if the field 'number' is '2', then I want to output '£20'.
Maybe you should start thinking more of:
help wrote:-Computed Field. This allows you to embed a computed field in your form. It is not visible to the user until after the form is submitted. It allows you to do simple arithmetic or string concatenation.
That way you won't need an UDT at all...
HTH.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
davidaldred
New Member
New Member
Posts: 5
Joined: Sat Apr 13, 2013 7:35 pm

Re: Formbuilder and UDT

Post by davidaldred »

Must admit I'd not realised that 'submit to UDT' was necessary as well as having the UDT on the submission page/response. Even having done that, though, I can't get anywhere; I still get just the text and no value returned by the UDT.

I'm now looking at the calculated field option. I have a field in the form called 'tickets'.

Immediately above the disposition field (which is 'store results for formbrowser'), I've added a calculated field called 'cost', and in the helpful list of variables it tells me the field is represented by the php variable $fid_43; so in the 'value to compute' box I've put $fid_43*10 . It's set to interpret variables as numeric.


The submission template is this:

Code: Select all

<h2>Thanks! Your submissions have been received.</h2>

{$cost}

Now if I complete the form with a 'tickets' value of 2, and submit it, I get

Thanks! Your submissions have been received.

0

..whereas I would be expecting to see '20' instead of '0'. What am I missing?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder and UDT

Post by Jo Morg »

davidaldred wrote:Must admit I'd not realised that 'submit to UDT' was necessary as well as having the UDT on the submission page/response. Even having done that, though, I can't get anywhere; I still get just the text and no value returned by the UDT.
... no... not as well as. Just instead of... But, as I said, the UDT is called either from the template (which doesn't populate the parameters) or from the disposition, which populates the parameters, but leaves to the UDT to do something with the data (echoing isn't an option here since the context is NOT a template call).
davidaldred wrote:Immediately above the disposition field (which is 'store results for formbrowser'), I've added a calculated field called 'cost', and in the helpful list of variables it tells me the field is represented by the php variable $fid_43; so in the 'value to compute' box I've put $fid_43*10 . It's set to interpret variables as numeric. The submission template is this:Code:<h2>Thanks! Your submissions have been received.</h2>{$cost}Now if I complete the form with a 'tickets' value of 2, and submit it, I get Thanks! Your submissions have been received.0..whereas I would be expecting to see '20' instead of '0'. What am I missing?
Well I just did a quick test and added two numeric to one of the already existing forms, and a computed field that with:

Code: Select all

$fld_29*$fld_30
on the submission template I used:

Code: Select all

{$testa} : {$fld_29}
{$testb} : {$fld_30}
{$testtotal} : {$fld_31} 
and it worked perfectly. Just as a reference: {$testa} and {$fld_29} represent the same field value.
Also I could even have used Smarty to do the math on the template. You may have to check if the fields hold the values you expect to find there.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
davidaldred
New Member
New Member
Posts: 5
Joined: Sat Apr 13, 2013 7:35 pm

Re: Formbuilder and UDT

Post by davidaldred »

Formbrowser was showing that data was being submitted in the field concerned (not the calculated one, the original field). It was a good point that this should have been checked before, though.

I then tried adding a further calculated field, and that one worked. I can't see any difference at all between the two, so I really don't know what was going on there - but it's now producing the figure i need. I've now deleted the old calculated field.

Thanks for your help on this - much appreciated.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder and UDT

Post by Jo Morg »

Glad you got it working! ;)
Could you please modify the original post subject by adding a [solved]? Thanks.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Locked

Return to “Modules/Add-Ons”