[Rt-commit] rt branch, admin_ui, updated. 6266b0c4da7fdb14762a40d32108200a7e4c3746
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sun Jan 3 21:59:07 EST 2010
The branch, admin_ui has been updated
via 6266b0c4da7fdb14762a40d32108200a7e4c3746 (commit)
from 675c00443258a264943237c6ccfbe492fcba9485 (commit)
Summary of changes:
lib/RT/Action/WithCustomFields.pm | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 6266b0c4da7fdb14762a40d32108200a7e4c3746
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Jan 4 10:58:43 2010 +0800
default value for cf
diff --git a/lib/RT/Action/WithCustomFields.pm b/lib/RT/Action/WithCustomFields.pm
index a95d197..9e2321a 100644
--- a/lib/RT/Action/WithCustomFields.pm
+++ b/lib/RT/Action/WithCustomFields.pm
@@ -33,7 +33,7 @@ sub _setup_custom_fields {
sub _setup_custom_field {
my $self = shift;
- my $cf = shift;
+ my $cf = shift;
my $render_as = $cf->type_for_rendering;
my $name = 'cf_' . $cf->id;
@@ -44,6 +44,30 @@ sub _setup_custom_field {
render_as => $render_as,
);
+ if ( $self->record ) {
+
+ # so we can find out default value
+ my $ocfvs = $self->record->custom_field_values( $cf->id );
+
+ if ( $ocfvs->count ) {
+
+ if ( $render_as eq 'Upload' ) {
+ # TODO handle file type input
+ }
+ else {
+ if ( $cf->max_values == 1 ) {
+ $args{default_value} = $ocfvs->first->content;
+ }
+ else {
+ $args{default_value} =
+ [ map { $_->content } @{ $ocfvs->items_array_ref } ];
+ }
+
+ }
+ }
+ }
+
+
if ( $render_as =~ /Select/i ) {
$args{valid_values} = [
{
@@ -75,7 +99,7 @@ sub _add_custom_field_values {
$id = $1 if $arg =~ /^cf_(\d+)$/; # this always happens
$self->_add_custom_field_value(
field => $1,
- value => $self->argument_value($arg)
+ value => $self->argument_value($arg),
);
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list