make widget stuff manglable
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field.pm
index 6e3fb2f..a15f880 100644 (file)
@@ -4,21 +4,20 @@ use Reaction::UI::WidgetClass;
 
 class Field, which {
 
-  has id   => (isa => 'Str', is => 'ro', lazy_build => 1);
-  has name => (isa => 'Str', is => 'ro', lazy_build => 1);
-
-  implements build_id   => as { shift->viewport->event_id_for('value'); };
-  implements build_name => as { shift->viewport->event_id_for('value'); };
-
-  widget renders [qw/label field message/
-                  => { id       => func('self', 'id'),
-                       name     => func('self', 'name'), }
-                 ];
-
-  field   renders [ string { $_{viewport}->value },   ];
-
-  label   renders [ string { $_{viewport}->label   }, ];
-  message renders [ string { $_{viewport}->message }, ];
+  before fragment widget {
+    if ($_{viewport}->can('value_string')) {
+      arg 'field_value' => $_{viewport}->value_string;
+    } else {
+      arg 'field_value' => ''; #$_{viewport}->value;
+    }
+  };
+
+  implements fragment label_fragment {
+    if (my $label = $_{viewport}->label) {
+      arg label => $label;
+      render 'label';
+    }
+  };
 
 };
 
@@ -32,26 +31,6 @@ Reaction::UI::Widget::Field
 
 =head1 DESCRIPTION
 
-=head1 ATTRIBUTES
-
-=head2 id
-
-Str, lazy builds.
-
-=head2 name
-
-Str, lazy builds.
-
-=head1 METHODS
-
-=head2 build_id
-
-Returns the viewport's C<event_id_for('value')>
-
-=head2 build_name
-
-Returns the viewport's C<event_id_for('value')>
-
 =head1 FRAGMENTS
 
 =head2 widget