r78624 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78623‎ | r78624 | r78625 >
Date:16:07, 20 December 2010
Author:yaron
Status:deferred
Tags:
Comment:
Fixed two bugs that caused the "preload=" parameter to be handled incorrectly for non-free-text fields: changed a '=' to '==' in an 'if' statement (d'oh!) and added handling for the correct preload value; both fixes thanks to werdna
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -559,10 +559,9 @@
560560 $default_value = $sub_components[1];
561561 } elseif ( $sub_components[0] == 'preload' ) {
562562 // free text field has special handling
563 - if ( $field_name == 'free text' || $field_name = '<freetext>' ) {
 563+ if ( $field_name == 'free text' || $field_name == '<freetext>' ) {
564564 $free_text_preload_page = $sub_components[1];
565565 } else {
566 - // this variable is not used
567566 $preload_page = $sub_components[1];
568567 }
569568 } elseif ( $sub_components[0] == 'show on select' ) {
@@ -660,9 +659,13 @@
661660 $cur_value = '';
662661 }
663662
664 - if ( $cur_value == null ) {
665 - // set to default value specified in the form, if it's there
666 - $cur_value = $default_value;
 663+ if ( is_null( $cur_value ) ) {
 664+ if ( $default_value ) {
 665+ // Set to the default value specified in the form, if it's there.
 666+ $cur_value = $default_value;
 667+ } elseif ( $preload_page ) {
 668+ $cur_value = SFFormUtils::getPreloadedText( $preload_page );
 669+ }
667670 }
668671
669672 // if the user is editing a page, and that page contains a call to

Status & tagging log