Page 1 of 1
[solved]Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 1:19 pm
by HarmO
I'm creating a personalised template in formbuilder 0.7.4,
i have a radiobutton group called "datum" and use this code in the template
Code: Select all
{section name=numloop loop=$datum->input}
{if $datum->label_parts == 1}
<label for="{$datum->input[numloop]->input_id}" class="inline">
{$datum->input[numloop]->input}
{$datum->input[numloop]->name|strip_tags}
</label>
{/if}
{/section}
Now it works fine, but the {$datum->input[numloop]->input_id} code does not return the id/name of the radiobutton. insted it stays empty.
I can't seem to find an other code that outputs this input id.
whit other input types i don't seem to have te problem.
Who can help me?
Re: Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 1:26 pm
by Jo Morg
HarmO wrote:I'm creating a personalised template in formbuilder 0.7.4,
Rollback or downgrade to 0.7.3.
0.7.4 has a few bugs that might be causing that.
Re: Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 1:35 pm
by HarmO
Downgrading will mean i need to redo all my forms, no?
not really keen on doing that...
is there no other way around?
Re: Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 1:50 pm
by HarmO
I found the first part of the id which is the id of the radio button group
but the it is followed by an underscore and the id of the field
(_0 or _1)
Re: Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 2:00 pm
by HarmO
Ok, i don't know if it is the right way to do it,
but i found a way a way around:
Knowing that the id starts with the id of the radiobutton group followed by a underscore and the id of the radiobutton.
some analysis shows that the radiobutton id itselfs starts at 0
i declare a var $i=0 and in at the end of the loop i add 1 to i{$i=$i+1}
Code: Select all
{if $datum->multiple_parts == 1}
{$i = "0"}
{section name=numloop loop=$datum->input}
{if $datum->label_parts == 1}
<label for="{$datum->input_id}_{$i}" class="inline">
{$datum->input[numloop]->input}{$i=$i+1}
{$datum->input[numloop]->name|strip_tags}</label>
{/if}
{/section}
Re: Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 2:19 pm
by Jo Morg
HarmO wrote:Downgrading will mean i need to redo all my forms, no?
No. You can export the forms as XML and re-import them back. AFAIK and giving credit to some other post here on the forum, it works also for a downgrade.
My previous warning comes from the fact that there have been quite a number of reports of bugs and issues with that version of FB, and if you find additional problems further down your development path, you may eventually have to downgrade all the same.
Re: [solved]Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 2:41 pm
by velden
I think you're already using the work around by putting the input inside the label. No use for 'for' attribute in that case I suppose. So just don't use it.
Re: [solved]Formbuilder template get radiobutton ID
Posted: Mon Jan 20, 2014 9:47 pm
by HarmO
Not quite Velden,
It is not completely the same if i add the for="" or not.
by adding the for="#SomeId" you can select the text, but if you don't place it, you need to really click on the radio button to select it. Even is the radio button is in the label tag (I used firefox 26.0 to check it).
Thanks for the feedback.
i hope this workaround will be useful for someone one day .