[Jifty-commit] r1059 - in jifty/trunk: lib/Jifty/Web/Form/Field

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon May 15 08:28:56 EDT 2006


Author: jesse
Date: Mon May 15 08:28:56 2006
New Revision: 1059

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web/Form/Field/Select.pm

Log:
 r13793 at hualien:  jesse | 2006-05-15 08:27:04 -0400
  My app uses some columns that refers_to other table, and I find that
  the default rendering of such column is inconsistent between update/create
  modes and the read one:
   the update/create versions use a select field that displays values of
   the name column of the target table (of the name method if exists, the id
   otherwise) whereas the "view" version uses the default render_value method
   of Field.pm, and thus displays the id of the target row (which is not
   the expected result IMHO.)
 
 
   - Frederic Blank  
 


Modified: jifty/trunk/lib/Jifty/Web/Form/Field/Select.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field/Select.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field/Select.pm	Mon May 15 08:28:56 2006
@@ -33,4 +33,20 @@
     '';
 }
 
+sub render_value {
+    my $self  = shift;
+    my $field = '<span';
+    $field .= qq! class="@{[ $self->classes ]}"> !;
+    my $value = $self->current_value;
+    if(defined $value) {
+        my @value = grep { $_->{value} eq $value }
+                        @{ $self->action->available_values($self->name) };
+        $value = $value[0]->{display} if scalar @value;
+    }
+    $field .= HTML::Entities::encode_entities(_($value)) if defined $value;
+    $field .= qq!</span>\n!;
+    Jifty->web->out($field);
+    return '';
+}
+
 1;


More information about the Jifty-commit mailing list