Radio button didn't behave correctly in my block

voyager

Joined: 2009-01-06
Posts: 13
Posted: Sun, 2009-10-04 22:05

Im work on my first module block to display two radio buttons to let user makes a choice:

<In my module block template file>
...
{if $user.isRegisteredUser}
{html_radios name="choices" values=$myIds output=$myChoices selected=2}
...

Where $myId and $myChoices are initiated as:
$myIds=array(1,2);
$myChoices=array('No','Yes');

When I enabled the module and block, the code does disaplyed a pair of radio buttons. But it always have the first button ("No") selected, even though I set "selected" to "2".

A view source showed the page:
<label><input type="radio" name="choosePerm" value="1" />No</label>
<label><input type="radio" name="choosePerm" value="2" checked="checked" />Yes</label>

Why the radio buttons didn't show the correct checked button?

Also, how could I add a callback function if user click one of the button?

I'd appreciate if you also can point to some exapmples.

Eric.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2009-10-04 22:36

I think you have to add selected to the {html_radios...}

http://www.smarty.net/manual/en/language.function.html.radios.php

You will need to find an existing example of how this works for callbacks. I am not well versed with this.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team