From 19deeeb595c200458ceaf0ecefb93aa8870d7153 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 7 Jul 2011 13:01:29 +0000 Subject: [PATCH] switch html5 form validation off for cancel buttons and in etemplate editor (or whenever any $ignore_validation expression is given) --- etemplate/inc/class.etemplate.inc.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/etemplate/inc/class.etemplate.inc.php b/etemplate/inc/class.etemplate.inc.php index 65b77cc50e..fe3be11d8b 100644 --- a/etemplate/inc/class.etemplate.inc.php +++ b/etemplate/inc/class.etemplate.inc.php @@ -247,6 +247,9 @@ class etemplate extends boetemplate self::$request->ignore_validation = $ignore_validation; self::$request->name_vars = self::$name_vars; + // tell html5 form validation NOT to validate + if ($ignore_validation) self::$form_options .= ' novalidate="novalidate"'; + if((int) $output_mode == 3) { self::$styles_included[$this->name] = True; @@ -1419,6 +1422,7 @@ class etemplate extends boetemplate case 'button': case 'buttononly': case 'cancel': // cancel button + if ($name == 'cancel' || stripos($name,'[cancel]') !== false) $type = 'cancel'; list($app) = explode('.',$this->name); list($img,$ro_img) = explode(',',$cell_options); if ($img[0] != '/' && strpos($img,'/') !== false && count($img_parts = explode('/',$img)) == 2) @@ -1458,6 +1462,7 @@ class etemplate extends boetemplate { $onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').$cell['onchange']; } + if ($type == 'cancel') $options .= ' novalidate="novalidate"'; // tell html5 form validation NOT to validate $html .= !$readonly ? html::submit_button($form_name,$label,$onclick, strlen($label) <= 1 || $cell['no_lang'],$options,$img,$app,$type == 'buttononly' ? 'button' : 'submit') : html::image($app,$ro_img,'',$options); @@ -1465,11 +1470,7 @@ class etemplate extends boetemplate $extra_label = False; if (!$readonly && $type != 'buttononly') // input button, are never submitted back! { - self::$request->set_to_process($form_name,$cell['type']); - if ($name == 'cancel' || stripos($name,'[cancel]') !== false) - { - self::$request->set_to_process($form_name,'cancel'); - } + self::$request->set_to_process($form_name,$type); } break; case 'hrule':