[Rt-devel] RE: [PATCH]: Data normalisation for multi-valued CFs in GUI create

Jesse Vincent jesse at bestpractical.com
Thu Feb 22 22:05:36 EST 2007




On Thu, Feb 22, 2007 at 06:53:01PM -0800, Philip Kime wrote:
> > Changing how R:I:W:CreateTicket calls Ticket->Create doesn't seem to
> me to win you 
> > anything and if you're writing code in Ticket->Create() that expects
> only one or the 
> > other, then you're doing it in the wrong place. 
> 
> Well, you're right - I am actually adding code to Ticket->Create() to
> reject ticket creation if their mandatory fields aren't set. As part of
> this processing, I'd like to use ->SingleValue to tell if I should be
> looking at empty strings or empty arrays. It's more OO and nice that
> way. If I have to do "ref $blah eq 'ARRAY', it's fine but not as neat.


We're already doing that:


from sub Create:


    foreach my $arg ( keys %args ) {
        next unless ( $arg =~ /^CustomField-(\d+)$/i );
        my $cfid = $1;
        foreach
          my $value ( UNIVERSAL::isa( $args{$arg} => 'ARRAY' ) ? @{ $args{$arg} } : ( $args{$arg} ) )
        {
            next unless ( length($value) );

            # Allow passing in uploaded LargeContent etc by hash reference
            $self->_AddCustomFieldValue(
                (UNIVERSAL::isa( $value => 'HASH' )
                    ? %$value
                    : (Value => $value)
                ),
                Field             => $cfid,
                RecordTransaction => 0,
            );
        }
    }


Which likely means that you want to work on _AddCustomFieldValue...which is getting your values all pulled apart already.


> I'm really only thinking of regularising it - the GUI behaves
> differently to REST and CommandByMail which put even single values in
> arrays so you always know what you're getting.
> 
> PK
> 

-- 


More information about the Rt-devel mailing list