X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2Fedit.html;h=09f7655d0a65225711411386164b44f2d236e1d4;hb=e13403cc8e687d852f6986985877eaf584bb257a;hp=285c85265ad50d756f58aabfda2dfe376adbb2b4;hpb=2b813b0948fe96f65e40c47e92edf99314e8d25e;p=freeside.git diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 285c85265..09f7655d0 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -114,6 +114,9 @@ Example: #we're in a popup (no title/menu/searchboxes) 'popup' => 1, + #if you need to access the submit button + 'submit_id' => 'mysubmitbuttonid', + #we're embedded (rows only: no header at all, no html_init, no error # display, no
, no hidden fields for table name or primary key, no # display of primary key, no submit button, no html_foot, no footer) @@ -231,7 +234,7 @@ Example: % my $url = $opt{'post_url'} || popurl(1)."process/$table.html"; -% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform', 'errormessage' => 'Please only numeric characters ' } }; +% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform' } }; $f->{'colspan'}, % 'required' => $f->{'required'}, +% +% #contact +% 'custnum' => $f->{'custnum'}, +% 'prospectnum' => $f->{'prospectnum'}, % ); % % $include_common{$_} = $f->{$_} foreach grep exists($f->{$_}), @@ -367,6 +374,8 @@ Example: % % my $layer_prefix_on = ''; % +% my $submitid = $opt{submit_id} ? $opt{submit_id} : ''; +% % my $include_sub = sub { % my %opt = @_; % @@ -382,7 +391,8 @@ Example: % ## set conditionname field values for validation. % if ($field eq 'conditionname') { % my $validate_field = $field . $fieldnum . '.after_event.run_delay'; -% $js_form_validate->{edit_topform}{$validate_field} = 'numeric'; +% $js_form_validate->{edit_topform}->{validate_fields}{$validate_field} = 'digits: true'; +% $js_form_validate->{edit_topform}->{error_message}{$validate_field} = 'Please only enter numbers here.'; % } % % my @include = @@ -390,6 +400,7 @@ Example: % 'field' => "$field$fieldnum", % 'id' => "$field$fieldnum", #separate? % 'label_id' => $field."_label$fieldnum", #don't want field0_label0... +% 'submit_id' => $submitid, % %include_common, % %opt, % ); @@ -628,7 +639,7 @@ Example: var newrow = <% include(@layer_opt, html_only=>1) |js_string %>; % #until the rest have html/js_only -% if ( $type eq 'selectlayers' || $type =~ /^select-cgp_rule_/ ) { +% if ( $type eq 'selectlayers' || $type =~ /^select-cgp_rule_/ || $type eq 'contact') { var newfunc = <% include(@layer_opt, js_only=>1) |js_string %>; % } else { var newfunc = ''; @@ -773,6 +784,18 @@ Example: : $opt{'html_bottom'} %> +% ## set extra field values for validation. ie price plan fields +% my $extra_fields_to_validate = $opt{'extra_fields_validate'}; +% my %validate_error_messages = ( +% 'digits: true' => 'Please only enter numbers here.', +% 'email: true' => 'Please enter a valid email here.', +% ); +% foreach my $extra_fields (keys %$extra_fields_to_validate) { +% my $validate_type = $extra_fields_to_validate->{$extra_fields}; +% $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type; +% $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type}; +% } + % unless ($opt{'embed'}) {
@@ -822,6 +845,7 @@ Example: my(%opt) = @_; +my $conf = new FS::Conf; my $curuser = $FS::CurrentUser::CurrentUser; #false laziness w/process.html @@ -831,7 +855,11 @@ my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || my $fields = $opt{'fields'} #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; || [ grep { $_ ne $pkey } fields($table) ]; -#my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; +my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; + +push @actualfields, $pkey; +push @actualfields, 'ip_addr' if $table eq 'svc_broadband'; +push @actualfields, 'usergroup' if ($table eq 'svc_broadband' && $conf->exists('svc_broadband-radius')); my $js_form_validate = {}; @@ -874,7 +902,7 @@ if ( $opt{'embed'} ) { $mode = 'error'; $object = $class->new( { - map { $_ => scalar($cgi->param($_)) } fields($table) + map { $_ => scalar($cgi->param($_)) } @actualfields }); &{$opt{'error_callback'}}( $cgi, $object, $fields, \%opt )