[Rt-commit] r7450 - in rt/branches/3.7-EXPERIMENTAL:
html/Widgets/Form
ruz at bestpractical.com
ruz at bestpractical.com
Wed Apr 4 17:51:13 EDT 2007
Author: ruz
Date: Wed Apr 4 17:51:12 2007
New Revision: 7450
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/Widgets/Form/Boolean
Log:
r4883 at cubic-pc: cubic | 2007-04-04 02:29:36 +0400
Boolean widget
* get rid of Boolean- prefix in name of field
* add InputOnly method
* use magic field trick to save a state of the checkbox
Modified: rt/branches/3.7-EXPERIMENTAL/html/Widgets/Form/Boolean
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Widgets/Form/Boolean (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Widgets/Form/Boolean Wed Apr 4 17:51:12 2007
@@ -1,16 +1,20 @@
<div id="form-box-<% lc $Name %>">
-<span class="description"><% $Description %></span>:
-<input type="checkbox" name="Boolean-<% $Name %>" <% $value && 'checked' %>" />
+<span class="description"><% $Description %></span>:\
+<& SELF:InputOnly, %ARGS &>
</div>
-<%INIT>
-my $value = defined $CurrentValue ? $CurrentValue : $EmptyValue;
-</%INIT>
<%ARGS>
$Name => undef,
$Description => undef,
-$EmptyValue => 0,
+</%ARGS>
+
+<%METHOD InputOnly>
+<%ARGS>
+$Name => undef,
$CurrentValue => undef,
</%ARGS>
+<input type="hidden" name="<% $Name %>" value="0" />\
+<input type="checkbox" name="<% $Name %>" <% $CurrentValue? 'checked="checked"': '' %>" />\
+</%METHOD>
<%METHOD Process>
<%ARGS>
@@ -20,7 +24,9 @@
$CurrentValue => 0,
</%ARGS>
<%INIT>
-return $Arguments->{ "Boolean-$Name" }? 1: 0;
+return $Arguments->{ $Name }? 1: 0
+ if defined $Arguments->{ $Name };
+return $CurrentValue;
</%INIT>
</%METHOD>
More information about the Rt-commit
mailing list