Gossamer Forum
Home : Products : DBMan SQL : Discussion :

<%if Name%><%Name%><%endif%>

Quote Reply
<%if Name%><%Name%><%endif%>
In the modify templates I have add tags like:
<input type="text" name="Name" value="<%if Name%><%Name%><%endif%>" size="20">

This is so that I don't have to type everthing again if I want to modify a listing. The problem is what code/tag to I add for:
1. Checkboxes
2. drop down
3. Pictures

Any help would be great.

Thanks

Anoosh
Quote Reply
Re: [needsupport] <%if Name%><%Name%><%endif%> In reply to
Did you find the solution?

I need this to

Fábio
Quote Reply
Re: [needsupport] <%if Name%><%Name%><%endif%> In reply to
You can do things like:

<%if Tag eq 'x'%>selected<%endif%>

for select lists and

<%if Tag eq 'x'%>checked<%endif%>

...for check boxes, where x is the value

Last edited by:

Paul: Mar 25, 2002, 11:39 AM
Quote Reply
Re: [Paul] <%if Name%><%Name%><%endif%> In reply to
TheStone gives me a better option

the select is working, but the checkbox isnīt

here is a copy,



Hi,

They'll be added in the next release. For now, you should create two
global templates called 'create_select' and create_checkbox', take a look
at the script below:

- create_select:
sub {
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
return if (lc $cols->{$col}->{'form_type'} ne 'select');
my $values;
my $selected = $tags->{home}->{cgi}->{$col};
my $form_values = $cols->{$col}->{'form_values'};
my $form_names = $cols->{$col}->{'form_names'};
if ($form_values and $form_names and ($#$form_values == $#$form_names)) {
for my $i (0..$#$form_values) {
exists $values->{@$form_values[$i]} or $values->{@$form_values
[$i]} = @$form_names[$i];
}
}
else {
$values = $cols->{$col}->{values};
}
return $tags->{home}->{disp}->select ( {
name => $col,
values => $values,
value => $selected,
blank => 0,
});
}

- create_checkbox:
sub {
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
return if (lc $cols->{$col}->{'form_type'} ne 'checkbox');
my $selected = $tags->{home}->{cgi}->{$col};
my $values = $cols->{$col}->{'form_values'};
my $names = $cols->{$col}->{'form_names'};
return $tags->{home}->{disp}->checkbox( {
name => $col,
values => $values,
value => $selected,
blank => 0 });
}

And then you put <%create_select('field_name')%>, <%create_checkbox%> into
your template file.

Hope that helps,
TheStone.</< body>
Quote Reply
Re: [assombracao] <%if Name%><%Name%><%endif%> In reply to
Make sure that the form_type property of that field should be 'checkbox'

TheStone.

B.
Quote Reply
Re: [TheStone] <%if Name%><%Name%><%endif%> In reply to
How can I sort the numbers in the select ?

If itīs less than 10, it be ok 0,1,2,3,4,5,6,7,8,9

But if itīs more than 10 it getīs too confused like 37,38,39,20,21,22,23,40,24,41 (this sequence)

What can I do to sort 11,12,13,14 ...

thanks

Fábio
Quote Reply
Re: [assombracao] <%if Name%><%Name%><%endif%> In reply to
Hum, another problem,

the select and the checkbos isnīt working for the modify form

whatīs going wrong?

for the add itīs ok

Thank you

Fábio
Quote Reply
Re: [assombracao] <%if Name%><%Name%><%endif%> In reply to
Hi,

You should change: my $selected = $tags->{home}->{cgi}->{$col};
To: my $selected = $tags->{values}->{$col};

Cheers,
TheStone.

B.