[solved]Formbuilder template get radiobutton ID

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

[solved]Formbuilder template get radiobutton ID

Post 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?
Last edited by HarmO on Mon Jan 20, 2014 2:00 pm, edited 1 time in total.
Kind regards,
HarmO
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder template get radiobutton ID

Post 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.
"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!
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: Formbuilder template get radiobutton ID

Post 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?
Kind regards,
HarmO
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: Formbuilder template get radiobutton ID

Post by HarmO »

I found the first part of the id which is the id of the radio button group

Code: Select all

{$datum->input_id}
but the it is followed by an underscore and the id of the field
(_0 or _1)
Kind regards,
HarmO
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: Formbuilder template get radiobutton ID

Post 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}
Kind regards,
HarmO
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder template get radiobutton ID

Post 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.
"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!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [solved]Formbuilder template get radiobutton ID

Post 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.
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: [solved]Formbuilder template get radiobutton ID

Post 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 .
Kind regards,
HarmO
Post Reply

Return to “Modules/Add-Ons”