Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[ ULTRAGlobals ] Error Radio button

Quote Reply
[ ULTRAGlobals ] Error Radio button
When use a radio button in the option To modify Link the value of the
selected button does not appear checked, the two used buttons appears
unselected. it can help me?

You have some pluguin that she returns SELECT eg: Format_Select_Field?

My code:
<!-- Delivery -->
<div class="row clear">
<label for="Contact_Name" class="name">Faz entrega em domicilio?:</label>
<div class="value">
<%Plugins::ULTRAGlobals::Format_Radio_Field('Entrega')%>

<%loop radio_loop%>
<input name="<%field_name%>" id="<%name%>" type="radio"
value="<%name%>" <%if selected%>checked<%endif%> />
<label for="<%name%>"><%value%></label>
<%endloop%>
</div>
</div>

__________________________________

HTML Results:
<!-- Delivery -->
<div class="row clear">
<label for="Contact_Name" class="name">Faz entrega em domicilio?:</label>
<div class="value">
<input name="Entrega" id="Nao" type="radio" value="Nao" />
<label for="Nao">Nao</label>
<input name="Entrega" id="Sim" type="radio" value="Sim" />
<label for="Sim">Sim</label>
</div>
</div>

____________________________________
Quote Reply
Re: [Janio] [ ULTRAGlobals ] Error Radio button In reply to
As per my email reply:

Having a look at the code, the problem seems to be that the function only works when values are passed in via the $IN param

What you could try, is in /Plugins/ULTRAGlobals.pm, find:

Code:
sub Format_Radio_Field {

my $field = $_[0];

...other code here

}

..and change it for something like:

Code:
sub Format_Radio_Field {

my $field = $_[0];

my @current_val_split;
if ($_[1]) {
@current_val_split = split /\n/, $_[1];
for (my $i = 0; $i <= $#current_val_split; $i++) { $current_val_split[$i] =~ s/\r//sig; }
} else {
@current_val_split = $IN->param($field);
}
my $vals;
foreach (@current_val_split) { $vals->{$_} = 1 }

my $schema = $DB->table('Links')->cols;
my $field_vals = $schema->{$field};
my @select_loop;
for (my $i = 0; $i <= 250; $i++) {
my $tmp;
if (!$field_vals->{form_values}[$i]) { last; }
$tmp->{value} = $field_vals->{form_values}[$i];
$tmp->{name} = $field_vals->{form_names}[$i];
#print qq|$tmp->{value} => $vals->{$tmp->{value}} <br />|;
if ($vals->{$tmp->{name}}) { $tmp->{selected} = 1; }
$tmp->{field_name} = $field;
push @select_loop, $tmp;

}

return { radio_loop => \@select_loop }

}

..then call it using:

Code:
<%Plugins::ULTRAGlobals::Format_Radio_Field('Entrega',$Entrega)%>

I'm *really* busy at the moment, so I'm afraid I don't have time to test that modification. Please let me know if it works, and if it does - I'll add the changes to the release version, so others can use this fix :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ ULTRAGlobals ] Error Radio button In reply to
Tks..

Ok,
now works perfectly