diff options
| author | Mitch Jackson <mitch@freeside.biz> | 2018-11-28 15:20:48 -0500 | 
|---|---|---|
| committer | Mitch Jackson <mitch@freeside.biz> | 2018-11-28 15:54:57 -0500 | 
| commit | efd203c04eac2ccc6590d7908b8629afb8e1d7df (patch) | |
| tree | 68271b0cf0e9febd07139cad60082b853f791eeb /FS/FS | |
| parent | a1cb420e2647d8b78d7169694145c2dd3b660448 (diff) | |
RT# 76309 Add validation for part_event_option.optionvalue
Diffstat (limited to 'FS/FS')
| -rw-r--r-- | FS/FS/part_event/Action.pm | 2 | ||||
| -rw-r--r-- | FS/FS/part_event_option.pm | 38 | 
2 files changed, 39 insertions, 1 deletions
| diff --git a/FS/FS/part_event/Action.pm b/FS/FS/part_event/Action.pm index c0c70b1c3..1916e40a1 100644 --- a/FS/FS/part_event/Action.pm +++ b/FS/FS/part_event/Action.pm @@ -85,6 +85,8 @@ hashref with the following values:  =item size - Size for text fields +=item validation - (optional) Validate optionvalue using the given object method, such as ut_textn, ut_email +  =item options - For checkbox-multiple and select, a list reference of available option values.  =item option_labels - For select, a hash reference of availble option values and labels. diff --git a/FS/FS/part_event_option.pm b/FS/FS/part_event_option.pm index 6df9e84c1..1421f6f0f 100644 --- a/FS/FS/part_event_option.pm +++ b/FS/FS/part_event_option.pm @@ -183,11 +183,19 @@ sub check {      $self->ut_numbern('optionnum')      || $self->ut_foreign_key('eventpart', 'part_event', 'eventpart' )      || $self->ut_text('optionname') -    #|| $self->ut_textn('optionvalue')      || $self->ut_anything('optionvalue') #http.pm content has \n    ;    return $error if $error; +  if ( my %option_fields = $self->option_fields ) { +    if ( my $option_field = $option_fields{ $self->optionname } ) { +      if ( my $validation_method = $option_field->{validation} ) { +        $error = $self->$validation_method('optionvalue'); +      } +    } +  } +  return $error if $error; +    $self->SUPER::check;  } @@ -203,6 +211,34 @@ sub insert_reason {  } +=item part_event + +Return the associated part_event row + +=cut + +sub part_event { +  qsearchs( part_event => { eventpart => shift->eventpart }) +} + +=item option_fields + +Return the option_fields from the associated part_event::action::$action + +=cut + +sub option_fields { +  my $part_event = shift->part_event +    or return; +  my $action = $part_event->action +    or return; + +  # For utility scripts, doesn't seem to be necessary +  # eval "require FS::part_event::Action::$action;"; + +  return "FS::part_event::Action::$action"->option_fields; +} +  =back  =head1 SEE ALSO | 
