Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | $this->setInputTypeHook( 'radiobutton', array( 'SFFormInputs', 'radioButtonHTML' ), array() ); |
66 | 66 | $this->setInputTypeHook( 'checkboxes', array( 'SFFormInputs', 'checkboxesHTML' ), array() ); |
67 | 67 | $this->setInputTypeHook( 'listbox', array( 'SFFormInputs', 'listboxHTML' ), array() ); |
| 68 | + $this->setInputTypeHook( 'combobox', array( 'SFFormInputs', 'comboboxHTML' ), array() ); |
68 | 69 | $this->setInputTypeHook( 'category', array( 'SFFormInputs', 'categoryHTML' ), array() ); |
69 | 70 | $this->setInputTypeHook( 'categories', array( 'SFFormInputs', 'categoriesHTML' ), array() ); |
70 | 71 | |
— | — | @@ -132,7 +133,7 @@ |
133 | 134 | * - this might make sense in some SF utils class, if it's useful in |
134 | 135 | * other places. |
135 | 136 | */ |
136 | | - function strReplaceOnce( $search, $replace, $subject) { |
| 137 | + function strReplaceFirst( $search, $replace, $subject) { |
137 | 138 | $firstChar = strpos( $subject, $search ); |
138 | 139 | if ( $firstChar !== false ) { |
139 | 140 | $beforeStr = substr( $subject, 0, $firstChar ); |
— | — | @@ -254,8 +255,9 @@ |
255 | 256 | } |
256 | 257 | } |
257 | 258 | // otherwise, parse it |
258 | | - if ( ! $got_form_def_from_cache ) |
| 259 | + if ( ! $got_form_def_from_cache ) { |
259 | 260 | $form_def = $wgParser->parse( $form_def, $this->mPageTitle, $wgParser->mOptions )->getText(); |
| 261 | + } |
260 | 262 | $wgParser->mStripState = $old_strip_state; |
261 | 263 | |
262 | 264 | // turn form definition file into an array of sections, one for each |
— | — | @@ -440,7 +442,7 @@ |
441 | 443 | $existing_page_content = str_replace( $existing_template_text, '{{{insertionpoint}}}', $existing_page_content ); |
442 | 444 | } |
443 | 445 | } else { |
444 | | - $existing_page_content = self::strReplaceOnce( $existing_template_text, '', $existing_page_content ); |
| 446 | + $existing_page_content = self::strReplaceFirst( $existing_template_text, '', $existing_page_content ); |
445 | 447 | } |
446 | 448 | // if this is not a multiple-instance template, and we've found |
447 | 449 | // a match in the source page, there's a good chance that this |
— | — | @@ -822,7 +824,7 @@ |
823 | 825 | // form values, see if the current input is part of that formula, |
824 | 826 | // and if so, substitute in the actual value |
825 | 827 | if ( $form_submitted && $generated_page_name != '' ) { |
826 | | - // this line appears unnecessary |
| 828 | + // this line appears to be unnecessary |
827 | 829 | // $generated_page_name = str_replace('.', '_', $generated_page_name); |
828 | 830 | $generated_page_name = str_replace( ' ', '_', $generated_page_name ); |
829 | 831 | $escaped_input_name = str_replace( ' ', '_', $input_name ); |
— | — | @@ -973,6 +975,8 @@ |
974 | 976 | if ( empty( $default_value ) ) { |
975 | 977 | $sfgJSValidationCalls[] = "validate_mandatory_radiobutton('$input_id', '$info_id')"; |
976 | 978 | } |
| 979 | + } elseif ( $input_type == 'combobox' ) { |
| 980 | + $sfgJSValidationCalls[] = "validate_mandatory_combobox('$input_id', '$info_id')"; |
977 | 981 | } elseif ( ( $form_field->template_field->is_list && $form_field->template_field->field_type == 'enumeration' && $input_type != 'listbox' ) || ( $input_type == 'checkboxes' ) ) { |
978 | 982 | $sfgJSValidationCalls[] = "validate_mandatory_checkboxes('$input_id', '$info_id')"; |
979 | 983 | } else { |
— | — | @@ -1267,6 +1271,12 @@ |
1268 | 1272 | $new_text = ""; |
1269 | 1273 | if ( !$embedded ) |
1270 | 1274 | $new_text = $wgParser->preprocess( str_replace( "{{!}}", "|", $form_page_title ), $this->mPageTitle, new ParserOptions() ); |
| 1275 | + |
| 1276 | + // keep it simple - if the form has already been submitted, i.e. this is |
| 1277 | + // just the redirect page, get rid of all the Javascript, to avoid JS errors |
| 1278 | + if ( $form_submitted ) { |
| 1279 | + $javascript_text = ''; |
| 1280 | + } |
1271 | 1281 | |
1272 | 1282 | return array( $form_text, "/*<![CDATA[*/ $javascript_text /*]]>*/", |
1273 | 1283 | $data_text, $new_text, $generated_page_name ); |