Page 2 of 3

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 12:17 pm
by johnboyuk1
Same issue I'm afraid, comes through on the email as 'unspecified'

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 12:53 pm
by Jo Morg
Hmmm try to replace {$test_field->input_id} with {$test_field->name}.
I'm almost sure the first should also work, but... I may have it wrong, being in a hurry and all :D

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 12:59 pm
by Jo Morg
Nope! disregard the above post... {$test_field->input_id} or {$fld_36->input_id} have to work: I just tested.

PS: the HTML field name should be something like name="cntnt01fbrp__36"

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 2:00 pm
by johnboyuk1
Thanks for your patience Jo - I must be doing something wrong... lets go through what I've done again...

Here's how I have FB set up:

Image

Here's the code in the 'advanced' tab of the send results field (I tried a few methods!):

Code: Select all

{if $test_field != "" && $test_field != "[unspecified]" }<strong>test_field</strong>: {$test_field}<br />{/if}
{$test_field}
{$fld_36}
{$fld_36_obj->name} = {$fld_36_obj->value}
{$m16e7dfbrp__36}
And here's the form template:

Code: Select all

{* DEFAULT FORM LAYOUT / pure CSS *}
{literal}
<__script__ type="text/javascript">
function fbht(htid)
	{
		var fbhtc=document.getElementById(htid);
		if (fbhtc)
			{
			if (fbhtc.style.display == 'none')
				{
				fbhtc.style.display = 'inline';
				}
			else
				{
				fbhtc.style.display = 'none';
				}
			}
}
</__script>
{/literal}
{$fb_form_header}
{if $fb_form_done == 1}
	{* This first section is for displaying submission errors *}
	{if isset($fb_submission_error) && $fb_submission_error}
		<div class="error_message">{$fb_submission_error}</div>
		{if isset($fb_show_submission_errors) && $fb_show_submission_errors}
			<div class="error">
			<ul>
			{foreach from=$fb_submission_error_list item=thisErr}
				<li>{$thisErr}</li>
			{/foreach}
			</ul>
		</div>
		{/if}
	{/if}
{else}
	{* this section is for displaying the form *}
	{* we start with validation errors *}
	{if isset($fb_form_has_validation_errors) && $fb_form_has_validation_errors}
		<div class="error_message">
		<ul>
		{foreach from=$fb_form_validation_errors item=thisErr}
			<li>{$thisErr}</li>
		{/foreach}
		</ul>
		</div>
	{/if}
	{if isset($captcha_error) && $captcha_error}
		<div class="error_message">{$captcha_error}</div>
	{/if}


{*
{LISECourses assign = junk}
<select class="form-control required"  title="Select Item" name="{$actionid}{$test_field->input_id}" id="{$actionid}{$test_field->input_id}">
 <option value="z">Select items</option>
  {foreach $items as $item}
    <option value="{$item->alias}">{$item->title}</option>
  {/foreach}
</select>
*}
{LISECourses assign = junk}
<select class="form-control required"  title="Select Item" name="{$actionid}{$fld_36->input_id}" id="test_field">
 <option value="">Select items</option>
  {foreach $items as $item}
    <option value="{$item->alias}">{$item->title}</option>
  {/foreach}
</select>

	{* and now the form itself *}
	{$fb_form_start}




	<div>{$fb_hidden}</div>
	<div{if $css_class != ''} class="{$css_class}"{/if}>
	{if $total_pages gt 1}<span>{$title_page_x_of_y}</span>{/if}

	{if isset($has_captcha) && $has_captcha == 1}
		<div class="captcha">{$graphic_captcha}{$title_captcha}<br />{$input_captcha}</div>
	{/if}
	<div class="submit">{$prev}{$submit}</div>
	</div>
	{$fb_form_end}
{/if}
{$fb_form_footer}
Where am I going wrong?!

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 2:05 pm
by Jo Morg

Code: Select all

{LISECourses assign = junk}
<select class="form-control required"  title="Select Item" name="{$actionid}{$fld_36->input_id}" id="test_field">
 <option value="">Select items</option>
  {foreach $items as $item}
    <option value="{$item->alias}">{$item->title}</option>
  {/foreach}
</select>
this bit MUST be inside the form meaning AFTER {$fb_form_start}.
And {$fb_hidden} should be right after form start.

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 2:49 pm
by johnboyuk1
ok - have moved it (code below) still not working. FYI when output to hTMl this is what the select form code is:

Code: Select all

<select class="form-control required" title="Select Item" name="m16e7d" id="test_field">
 <option value="">Select items</option>
      <option value="a_test">A test</option>
      <option value="another-test">Another test</option>
       </select>

Code: Select all

{* DEFAULT FORM LAYOUT / pure CSS *}
{literal}
<__script__ type="text/javascript">
function fbht(htid)
	{
		var fbhtc=document.getElementById(htid);
		if (fbhtc)
			{
			if (fbhtc.style.display == 'none')
				{
				fbhtc.style.display = 'inline';
				}
			else
				{
				fbhtc.style.display = 'none';
				}
			}
}
</__script>
{/literal}
{$fb_form_header}
{if $fb_form_done == 1}
	{* This first section is for displaying submission errors *}
	{if isset($fb_submission_error) && $fb_submission_error}
		<div class="error_message">{$fb_submission_error}</div>
		{if isset($fb_show_submission_errors) && $fb_show_submission_errors}
			<div class="error">
			<ul>
			{foreach from=$fb_submission_error_list item=thisErr}
				<li>{$thisErr}</li>
			{/foreach}
			</ul>
		</div>
		{/if}
	{/if}
{else}
	{* this section is for displaying the form *}
	{* we start with validation errors *}
	{if isset($fb_form_has_validation_errors) && $fb_form_has_validation_errors}
		<div class="error_message">
		<ul>
		{foreach from=$fb_form_validation_errors item=thisErr}
			<li>{$thisErr}</li>
		{/foreach}
		</ul>
		</div>
	{/if}
	{if isset($captcha_error) && $captcha_error}
		<div class="error_message">{$captcha_error}</div>
	{/if}

	{* and now the form itself *}
	{$fb_form_start}


	<div>{$fb_hidden}</div>

{LISECourses assign = junk}
<select class="form-control required"  title="Select Item" name="{$actionid}{$fld_36->input_id}" id="test_field">
 <option value="">Select items</option>
  {foreach $items as $item}
    <option value="{$item->alias}">{$item->title}</option>
  {/foreach}
</select>

	<div{if $css_class != ''} class="{$css_class}"{/if}>
	{if $total_pages gt 1}<span>{$title_page_x_of_y}</span>{/if}

	{if isset($has_captcha) && $has_captcha == 1}
		<div class="captcha">{$graphic_captcha}{$title_captcha}<br />{$input_captcha}</div>
	{/if}
	<div class="submit">{$prev}{$submit}</div>
	</div>
	{$fb_form_end}
{/if}
{$fb_form_footer}

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 3:14 pm
by Jo Morg

Code: Select all

<select class="form-control required" title="Select Item" name="m16e7d" id="test_field">
name="m16e7d" means the {$actionid} is working but {$fld_36} is probably wrong.
Again {$actionid}{$test_field->input_id} should work.

To see the ouput of the field use this:

Code: Select all

<pre>{$test_field|print_r:1}</pre>
and to see all fields, names aliases and all other object properties use this:

Code: Select all

<pre>{$fields|print_r:1}</pre>
You should be able to debug the form. And use just {$test_field} on the email template... lets see what happens.

Re: FormBuilder dropdown with data from LISE

Posted: Wed Oct 02, 2019 4:15 pm
by johnboyuk1
ok, these are the fields.. which are the 2 fields in FB - the text input and the email send.

What I dont understand (so having trouble working out how to solve!) is how the custom select box is supposed to transfer its data into the empty text input (field 36) ... this is obviously the part of the process thats going wrong

Code: Select all

Array
(
    [fbrp__36] => stdClass Object
        (
            [id] => 36
            [display] => 1
            [required] => 0
            [required_symbol] => 
            [css_class] => 
            [helptext] => 
            [field_helptext_id] => fbrp_ht_36
            [valid] => 1
            [error] => 
            [hide_name] => 0
            [has_label] => 1
            [needs_div] => 1
            [name] => test_field
            [input] => 


            [logic] => 
            [values] => 
            [value] => 
            [smarty_eval] => 0
            [multiple_parts] => 0
            [label_parts] => 1
            [type] => Text Input
            [input_css_id] => test_field
            [input_id] => fbrp__36
            [alias] => test_field
        )

    [fbrp__35] => stdClass Object
        (
            [id] => 35
            [display] => 0
            [required] => 0
            [required_symbol] => 
            [css_class] => 
            [helptext] => 
            [field_helptext_id] => fbrp_ht_35
            [valid] => 1
            [error] => 
            [hide_name] => 0
            [has_label] => 1
            [needs_div] => 1
            [name] => Send results
            [input] => 
            [logic] => 
            [values] => 
            [value] => 
            [smarty_eval] => 0
            [multiple_parts] => 0
            [label_parts] => 1
            [type] => *Email Results to set Address(es)
            [input_css_id] => fbrp__35
            [input_id] => fbrp__35
            [alias] => send_results
        )

)

Re: FormBuilder dropdown with data from LISE

Posted: Thu Oct 03, 2019 12:07 pm
by Jo Morg
As you can see input_id is filled so {$test_field->input_id} HAS to output something...

Re: FormBuilder dropdown with data from LISE

Posted: Thu Oct 03, 2019 1:11 pm
by johnboyuk1
But is it filled with 'nothing' as we've created a blank Text Input field?
Plus, those values are the state as the page has loaded - before anything is done with the dropdown selector

Re: FormBuilder dropdown with data from LISE

Posted: Thu Oct 03, 2019 1:29 pm
by Jo Morg
johnboyuk1 wrote:But is it filled with 'nothing' as we've created a blank Text Input field?
Plus, those values are the state as the page has loaded - before anything is done with the dropdown selector
It doesn't really matter unless we need file inputs which FB handles differently. For FB what matters is the field name as that is what tells FB what field is being filled with what value(s). If you defined the input as dropdown in FB there was no easy way to make the options be generated dynamically. This way FB doesn't care how the field value is generated. As you can have custom validation you can even check if the options fall inside the available range of options in case that is critical.
So if the field name is correct (which wasn't as we could see from the generated name='"" field parameter) FB sees it. The form HTML has to be valid too, but other than that, it has to work. I do it all the time. You could even have checkboxes, multiselectors, and javascript auto generated fields and FB would see those as textinputs if the HTML is correct.

Re: FormBuilder dropdown with data from LISE

Posted: Thu Oct 03, 2019 1:41 pm
by johnboyuk1
Thanks for continuing to help me out! Because I'm not entirely sure how this is/supposed to work I'm having trouble following and working out where I'm going wrong?

You can see the last template in the post further above, and also a screen grab showing the fields set up through FB... have I done this part correctly - does anything special need to go in the advance tab for this text input field?

Have just added an extra text input field to the form to make sure that comes through the email ok - and it does

So the issue is with the dropdown not 'replacing' the value in the Text Input ... and therefore showing as unspecified ... so where am I going wring with this, is FB supposed to replace this value just because we've given them the same names?

Re: FormBuilder dropdown with data from LISE

Posted: Fri Oct 04, 2019 12:47 pm
by Jo Morg
johnboyuk1 wrote: ... so where am I going wring with this, is FB supposed to replace this value just because we've given them the same names?
Well yes!
I'm not sure what was that you have done wrong, but the HTML rendered is not correct:

Code: Select all

<select class="form-control required" title="Select Item" name="m16e7d" id="test_field">
where name="m16e7d" seems to mean that only the {$actionid} is being rendered when
{$actionid}{$test_field->input_id} should be rendered i.e. name="m16e7dfbrp__36".

As I can't reproduce the error I'm assuming it's something with your template, a typo or something, but i can't debug it... :) You'll have to double check it to understand why it is not rendering. There is nothing else in particular you have to do, as you have the alias correctly set (I wouldn't make the alias the same as the field name in FB Field settings but I don't think that's the issue).

Re: FormBuilder dropdown with data from LISE

Posted: Fri Oct 04, 2019 1:22 pm
by johnboyuk1
The form html is rendering correctly - we must have done something since that post, here's how the form renders to html now:

Code: Select all

<select class="form-control required" title="Select Item" name="m16e7dfbrp__36" id="m16e7dfbrp__36">
 <option value="" selected="selected">Select items</option>
      <option value="a_test">A test</option>
      <option value="another-test">Another test</option>
      <option value="the_thinking_partnership">The Thinking Partnership</option>
  
</select>
But I still get 'unspecified' in the email .. :(

Re: FormBuilder dropdown with data from LISE

Posted: Tue Oct 08, 2019 8:52 am
by johnboyuk1
If anyone has any ideas on making this work it'd be greatly appreciated! I'm pulling my hair out ... ;)