Radiobuttons Form - How To Check The First One

I have this form:

  

{foreach from=$udata_array key=“d” item=“usid”}





{/foreach}


  • {$usid.firstname} {$usid.lastname}
  • {$usid.fields[‘41’]}
  • {$usid.fields[‘42’]}

{include file=“buttons/button.tpl” but_text=__(“choose”) but_name=“dispatch[my_changes.my_pass]” but_role=“select” but_meta=“ty-btn__primary”}

{capture name="mainbox_title"}{__("choose_user")}{/capture}

and with the checked="checked" attribute I get my last radio button checked. I want the first one to be checked. Is there any way to do this?

Thank you in advance.

found it!

{$i = 0}

  

{foreach from=$udata_array key=“d” item=“usid”}





{$i = $i + 1}
{/foreach}


  • {$usid.firstname} {$usid.lastname}
  • {$usid.fields[‘41’]}
  • {$usid.fields[‘42’]}

{include file=“buttons/button.tpl” but_text=__(“choose”) but_name=“dispatch[my_changes.my_pass]” but_role=“select” but_meta=“ty-btn__primary”}

{capture name="mainbox_title"}{__("choose_user")}{/capture}

I just added a counter and then an if statement.

found it!

{$i = 0}

  

{foreach from=$udata_array key=“d” item=“usid”}





{$i = $i + 1}
{/foreach}


  • {$usid.firstname} {$usid.lastname}
  • {$usid.fields[‘41’]}
  • {$usid.fields[‘42’]}

{include file=“buttons/button.tpl” but_text=__(“choose”) but_name=“dispatch[my_changes.my_pass]” but_role=“select” but_meta=“ty-btn__primary”}

{capture name="mainbox_title"}{__("choose_user")}{/capture}

I just added a counter and then an if statement.

You can also use

{$smarty.foreach.users.first}

where 'users' is specified in foreach as name like this

{foreach from=$udata_array key="d" item="usid" name="users"}

Final solution

  

{foreach from=$udata_array key=“d” item=“usid” name=“users”}





{/foreach}


  • {$usid.firstname} {$usid.lastname}
  • {$usid.fields[‘41’]}
  • {$usid.fields[‘42’]}

{include file=“buttons/button.tpl” but_text=__(“choose”) but_name=“dispatch[my_changes.my_pass]” but_role=“select” but_meta=“ty-btn__primary”}

{capture name="mainbox_title"}{__("choose_user")}{/capture}

Final solution

  

{foreach from=$udata_array key=“d” item=“usid” name=“users”}





{/foreach}


  • {$usid.firstname} {$usid.lastname}
  • {$usid.fields[‘41’]}
  • {$usid.fields[‘42’]}

{include file=“buttons/button.tpl” but_text=__(“choose”) but_name=“dispatch[my_changes.my_pass]” but_role=“select” but_meta=“ty-btn__primary”}

{capture name="mainbox_title"}{__("choose_user")}{/capture}

You can also use

{$smarty.foreach.users.first}

where 'users' is specified in foreach as name like this

{foreach from=$udata_array key="d" item="usid" name="users"}

I'll ceck these two thanks!

It works like a charm :) better solution, thank you again!

It works like a charm :) better solution, thank you again!

You are welcome :)

Glad to hear that you solved your problem