Page 1 of 1

Accessibility on Form Builder

Posted: Tue Nov 07, 2006 12:00 pm
by cuhlcannon
I am trying to make a form template in form builder that actually makes an accessible form. This is where static text added is a fieldset wrapping the containing items, the form itself is a definition list (something I think is appropriate as the labels are in a sense definitions of the  fields they label) and it incorporates multiple radio group etc.

If someone could aide me in the smarty part of it, I would be greatly appreciative, or even some of the accessibility stuff.

I have tried the following:

{$hidden}

{if $total_pages gt 1}{$title_page_x_of_y}{/if}

{foreach from=$fields item=entry}
  {if $entry->display == 1}
    {strip}
{if $entry->type == '-Static Text'}
{$entry->name}
{else}

{if $entry->required == 1 || $entry->css_class != ''} class="
{if $entry->required == 1}
required
{/if}
{if $entry->required == 1 && $entry->css_class != ''} {/if}
{if $entry->css_class != ''}
{$entry->css_class}
{/if}
"
{/if}
{if $entry->hide_name == 0}
input_id}">{$entry->name}
{if $entry->required_symbol != ''}
{$entry->required_symbol}
{/if}
{/if}

{if $entry->multiple_parts == 1}

{foreach from=$entry->input item=part}
{$part->name}
{$part->input}
{/foreach}

{else}
{$entry->input}
{/if}
{if $entry->valid == 0} <--- {/if}

{/if}
    {/strip}
  {/if}
{/foreach}

{$prev}{$submit}

Re: Accessibility on Form Builder

Posted: Tue Nov 07, 2006 5:05 pm
by calguy1000
Cuhl and I found a solution  this in the IRC channel, here's the resulting template.

Note, there's also a one line fix in FormBuilder/classes/Form.class.php to get the template working properly
check out the svn repository for the formbuilder module and you'll see it.

Code: Select all

{$hidden}
<div{if $css_class != ''} class="{$css_class}"{/if}>
{assign var=open value=0}
{if $total_pages gt 1}<div class="status">{$title_page_x_of_y}</div>{/if}
{foreach from=$fields item=entry}
	  {if $entry->display == 1}
	    	{strip}
			{if $entry->type == '-Static Text'}
                        {if $open == 1 }</fieldset>{assign var=open value=0}{/if}
			<fieldset>{assign var=open value=1}
                        <legend>{$entry->name}</legend>{$entry->input}
			{else}
				{if $entry->required == 1 || $entry->css_class != ''} class=" 
					{if $entry->required == 1}
						required
					{/if}
					{if $entry->required == 1 && $entry->css_class != ''} {/if}
					{if $entry->css_class != ''}
						{$entry->css_class}
					{/if}
					"
				{/if}
				{if $entry->hide_name == 0}
					<label for="{$entry->input_id}">{$entry->name}</label>
					{if $entry->required_symbol != ''}
						{$entry->required_symbol}
					{/if}
				{/if}
				{if $entry->multiple_parts == 1}
				<dl>
					{foreach from=$entry->input item=part}
						<dt>{$part->name}</dt>
						<dd>{$part->input}</dd>
					{/foreach}
				</dl>
				{else}
				{$entry->input}
				{/if}
				{if $entry->valid == 0} <--- {/if}
			{/if}
	    	{/strip}
	  {/if}
{/foreach}
{if $open == 1}</fieldset>{assign var=open value=0}{/if}
<div class="submit">{$prev}{$submit}</div>
</div>

Re: Accessibility on Form Builder

Posted: Tue Nov 07, 2006 5:12 pm
by cuhlcannon
Got another change to the form, to incorporate the required class and star into the label. This should be accessible now:
{$hidden}

{assign var=open value=0}
{if $total_pages gt 1}{$title_page_x_of_y}{/if}
{foreach from=$fields item=entry}
  {if $entry->display == 1}
    {strip}
{if $entry->type == '-Static Text'}
                        {if $open == 1 }{assign var=open value=0}{/if}
{assign var=open value=1}
                        {$entry->name}
{else}
{if $entry->hide_name == 0}
input_id}"
{if $entry->required == 1 || $entry->css_class != ''} class="
{if $entry->required == 1}
required
{/if}
{if $entry->required == 1 && $entry->css_class != ''} {/if}
{if $entry->css_class != ''}
{$entry->css_class}
{/if}
"
{/if}
>{$entry->name}
{if $entry->required_symbol != ''}
{$entry->required_symbol}
{/if}
{$entry->input}
{/if}
{if $entry->multiple_parts == 1}

{foreach from=$entry->input item=part}
{$part->name}
{$part->input}
{/foreach}

{/if}
{if $entry->valid == 0} <--- {/if}
{/if}
    {/strip}
  {/if}
{/foreach}
{if $open == 1}{assign var=open value=0}{/if}
{$prev}{$submit}