Formbuilder 1.1 attribute 'for'

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
andrewvideouk
Forum Members
Forum Members
Posts: 156
Joined: Thu Aug 20, 2020 10:49 pm

Formbuilder 1.1 attribute 'for'

Post by andrewvideouk »

Hi guys.

I am having problems errors with a forms. I am getting a errors like 'The value of the for attribute of the label element must be the ID of a non-hidden form control." label for="fbrp__40">
I do i need the attribute and how do I take it out. ? Should it be a ID attribute?

Thank you.

Code: Select all

<!-- Source: https://cmscanbesimple.org/blog/formbuilder-template-and-stylesheet -->
{* Based on the default FormBuilder pure CSS template *}
<__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>
{$fb_form_header}
{if $fb_form_done == 1}
	{* +++++ 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>fffffff
			{/foreach}
			</ul>
		</div>
		{/if}
	{/if}
{else}
	{* +++++ Show The Form Itself +++++ *}
	{$fb_form_start}
	{$fb_hidden}
	<div{if $css_class != ''} class="{$css_class}"{/if}>
	{if $total_pages gt 1}<span>{$title_page_x_of_y}</span>{/if}
	{foreach from=$fields item=entry}
		{if $entry->display == 1}
			{strip}
			{if $entry->needs_div == 1}
				<div
				{if $entry->required == 1 || $entry->css_class != '' || $entry->valid == 0} class="
					{if $entry->required == 1}required{/if}
					{if $entry->css_class != ''} {$entry->css_class}{/if}
					{if $entry->valid == 0} fb_invalid{/if}
					"
				{/if}
				>
			{/if}

			{if $entry->hide_name == 0}
				<label{if $entry->multiple_parts != 1} for="{$entry->input_id}"{/if}>
					{if $entry->valid == 0}<span class="formbuilder_text_error">{/if}
						{$entry->name}{if $entry->required_symbol != ''}&nbsp;{$entry->required_symbol}{/if}
					{if $entry->valid == 0}</span>{/if}
				</label>
			{/if}

			{if $entry->multiple_parts == 1}
				{section name=numloop loop=$entry->input}
					{if $entry->label_parts == 1}
						<div>{$entry->input[numloop]->input}&nbsp;{$entry->input[numloop]->name}</div>
					{else}
						{$entry->input[numloop]->input}
					{/if}
					{if isset($entry->input[numloop]->op) && $entry->input[numloop]->op}{$entry->input[numloop]->op}{/if}
				{/section}
			{else}
				{if $entry->valid == 0}<div class="formbuilder_field_error">{/if}
					{if $entry->smarty_eval == '1'}{eval var=$entry->input}{else}{$entry->input}{/if}
				{if $entry->valid == 0}</div>{/if}
			{/if}

			{if $entry->helptext != ''}
				&nbsp;<a href="javascript:fbht('{$entry->field_helptext_id}')"><img src="modules/FormBuilder/images/info-small.gif" alt="Help" /></a>
				<span id="{$entry->field_helptext_id}" style="display:none" class="fbr_helptext">{$entry->helptext}</span>
			{/if}

			{if $entry->needs_div == 1}</div>{/if}
			{/strip}
		{/if}
	{/foreach}
	{if $has_captcha == 1}
	<div>
		{if isset($captcha_error) && $captcha_error}<span class="formbuilder_text_error">{/if}
			<label>Spam protection {$entry->required_symbol}</label>
		{if isset($captcha_error) && $captcha_error}</span>{/if}
		<div>
			{$title_captcha}
		
			{if isset($captcha_error) && $captcha_error}<span class="formbuilder_field_error">{/if}
{$input_captcha}				
{$graphic_captcha}		
				
			{if isset($captcha_error) && $captcha_error}</span>{/if}
		</div>
	</div>
	{/if}
	{if isset($prev) && $prev}
		<div><label>&nbsp;</label>{$prev}</div>
	{/if}
	<div><label>&nbsp;</label>{$submit}</div>
	</div>
{$fb_form_end}
{/if}
{$fb_form_footer}
andrewvideouk
Forum Members
Forum Members
Posts: 156
Joined: Thu Aug 20, 2020 10:49 pm

Re: Formbuilder 1.1 attribute 'for'

Post by andrewvideouk »

I taken out the ' for="{$entry->input_id}" ' and it works still but I would like know what is used for?

Cheers
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Formbuilder 1.1 attribute 'for'

Post by velden »

andrewvideouk
Forum Members
Forum Members
Posts: 156
Joined: Thu Aug 20, 2020 10:49 pm

Re: Formbuilder 1.1 attribute 'for'

Post by andrewvideouk »

yes I seen the page already to check it was. Which its say 'for element_id Specifies the id of the form element the label should be bound to"
But I am still no wiser what it does and why W3schools its allow and w3 validator says invalid.
I am trying to get site to pass w3 basicy.

I well have to do more testing see if works on all platforms with out the tag.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Formbuilder 1.1 attribute 'for'

Post by velden »

As far as I now the for attribute only makes the label 'clickable'. For check boxes/radio buttons it toggles the element value. For other elements it puts the focus/cursos to/in that element.
andrewvideouk
Forum Members
Forum Members
Posts: 156
Joined: Thu Aug 20, 2020 10:49 pm

Re: Formbuilder 1.1 attribute 'for'

Post by andrewvideouk »

Thank you very much. That is very helpful. I never thought about it toggles the element value. I wel add some check boxes radio buttons and see whats happends. At this in time. I don't need any check boxes radio buttons on my forms. Knowing my luck I might need them later. I could do a if statement to check if its a check box or radio buttons then put in the 'for' attribute. Then at lease it well pass the W3c most of time.

I well let you know how I get on.
Post Reply

Return to “Modules/Add-Ons”