Changeset 2480


Ignore:
Timestamp:
10/08/21 18:29:39 (3 years ago)
Author:
nanardon
Message:

Allow to force from config the attribute type

Location:
trunk/LATMOS-Accounts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm

    r2461 r2480  
    685685sub obj_attr_allowed_values { 
    686686    my ($self, $otype, $attr) = @_; 
    687     if ($self->_allowed_values && 
    688         $self->_allowed_values->SectionExists("$otype.$attr")) { 
    689         return grep { defined($_) } $self->_allowed_values->val("$otype.$attr", 'allowed'); 
    690     } 
    691     return(); 
     687    return grep { defined($_) } $self->obj_attr_param($otype, $attr, 'allowed'); 
    692688} 
    693689 
     
    715711    } 
    716712    return 1; 
     713} 
     714 
     715=head2 obj_attr_param ( $otype, $attr, $param ) 
     716 
     717Return, if any, the paramater $param for this attribute from allowed_values config file 
     718 
     719=cut 
     720 
     721sub obj_attr_param { 
     722    my ( $self, $otype, $attr, $param ) = @_; 
     723 
     724    if ( $self->_allowed_values && 
     725        $self->_allowed_values->SectionExists("$otype.$attr")) { 
     726        return $self->_allowed_values->val( "$otype.$attr", $param ); 
     727    } 
     728    return; 
    717729} 
    718730 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Attributes.pm

    r2478 r2480  
    405405sub form_type { 
    406406 
     407    if (my $type = $_[0]->base->obj_attr_param( $_[0]->otype, $_[0]->name, 'type' ) ) { 
     408        # Forced from config: 
     409        return uc($type); 
     410    } 
     411 
    407412    my @values = $_[0]->can_values; 
    408413 
    409414    $_[0]->readonly ? 'LABEL' : 
    410415    $_[0]->{formtype} ? $_[0]->{formtype} : 
    411     $_[0]->has_values_list ? ( scalar(@values) > 15 ? 'LIST' : 'SELECT') : 
     416    $_[0]->has_values_list ? ( scalar(@values) > 5 ? 'LIST' : 'SELECT') : 
    412417    $_[0]->real_form_type 
    413418} 
  • trunk/LATMOS-Accounts/man/man5/la-allowed-values.ini.pod

    r2479 r2480  
    2828The list of value allowed for this attribute 
    2929 
     30=head3 type 
     31 
     32Force the attribute type: LIST, SELECT, DATE, ... 
     33 
    3034=head1 EXAMPLE 
    3135 
Note: See TracChangeset for help on using the changeset viewer.