summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util/FormHTML.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-11-11 12:04:16 +0100
committerYorhel <git@yorhel.nl>2008-11-11 12:04:16 +0100
commit0ac8f104fc9088c9980f0432e2569348cc833dc7 (patch)
treec573285507e2cf2c1b98aed509183c3f99c380f3 /lib/VNDB/Util/FormHTML.pm
parent11a06966db46eca56c4077775931767f6c93d6b9 (diff)
User settings editing now works, and some small bugfixes and style changes
I still don't really like the form creation and handling code... it's just ugly and I doubt anyone would be able to understand what I'm doing.
Diffstat (limited to 'lib/VNDB/Util/FormHTML.pm')
-rw-r--r--lib/VNDB/Util/FormHTML.pm47
1 files changed, 43 insertions, 4 deletions
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 4df8d552..250449ab 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -76,15 +76,48 @@ sub htmlFormError {
# Type Options
# input short, name, width
# passwd short, name
-# static content
+# static content, label
+# check name, short, (value)
+# select name, short, options
+# part title
+# TODO: Find a way to write this function in a readable way...
sub htmlFormPart {
my($self, $frm, $fp) = @_;
my($type, %o) = @$fp;
local $_ = $type;
- Tr !/static/ ? (class => 'newfield') : ();
+
+ if(/part/) {
+ Tr class => 'newpart';
+ td colspan => 2, $o{title};
+ end;
+ return;
+ }
+
+ if(/check/) {
+ Tr class => 'newfield';
+ td class => 'label';
+ lit '&nbsp;';
+ end;
+ td class => 'field';
+ input type => 'checkbox', class => 'checkbox', name => $o{short}, id => $o{short},
+ value => $o{value}||'true', $frm->{$o{short}} ? ( checked => 'checked' ) : ();
+ label for => $o{short};
+ lit $o{name};
+ end;
+ end;
+ end;
+ return;
+ }
+
+ Tr $o{name}||$o{label} ? (class => 'newfield') : ();
td class => 'label';
- label for => $o{short}, $o{name} if $o{short} && $o{name};
- lit '&nbsp;' if !$o{short} || !$o{name};
+ if($o{short} && $o{name}) {
+ label for => $o{short}, $o{name} ;
+ } elsif($o{label}) {
+ txt $o{label};
+ } else {
+ lit '&nbsp;';
+ }
end;
td class => 'field';
if(/input/) {
@@ -98,6 +131,12 @@ sub htmlFormPart {
if(/static/) {
lit $o{content};
}
+ if(/select/) {
+ Select name => $o{short}, id => $o{short};
+ option value => $_->[0], $frm->{$o{short}} eq $_->[0] ? (selected => 'selected') : (), $_->[1]
+ for @{$o{options}};
+ end;
+ }
end;
end;
}