http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90516

Revision: 90516
Author:   nad
Date:     2011-06-21 10:13:49 +0000 (Tue, 21 Jun 2011)
Log Message:
-----------
checkbox values were always being set to true when forms saved from edit view

Modified Paths:
--------------
    trunk/extensions/RecordAdmin/RecordAdmin.php
    trunk/extensions/RecordAdmin/RecordAdmin_body.php

Modified: trunk/extensions/RecordAdmin/RecordAdmin.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin.php        2011-06-21 09:45:06 UTC 
(rev 90515)
+++ trunk/extensions/RecordAdmin/RecordAdmin.php        2011-06-21 10:13:49 UTC 
(rev 90516)
@@ -10,7 +10,7 @@
  * @author Siebrand Mazeland
  * @licence GNU General Public Licence 2.0 or later
  */
-define( 'RECORDADMIN_VERSION', '1.2.3, 2011-06-08' );
+define( 'RECORDADMIN_VERSION', '1.2.4, 2011-06-21' );
 
 $dir = dirname( __FILE__ ) . '/';
 $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php';

Modified: trunk/extensions/RecordAdmin/RecordAdmin_body.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin_body.php   2011-06-21 09:45:06 UTC 
(rev 90515)
+++ trunk/extensions/RecordAdmin/RecordAdmin_body.php   2011-06-21 10:13:49 UTC 
(rev 90516)
@@ -118,14 +118,17 @@
                                                for( j = 0; j < tags.length; 
j++ ) {
                                                        var inputs = 
form.getElementsByTagName( tags[j] );
                                                        for( k = 0; k < 
inputs.length; k++ ) {
-                                                               var multi = 
jQuery( inputs[k] ).val();
-                                                               if( typeof( 
multi ) == 'object' ) multi = multi.join('\\n');
-                                                               var key = type 
+ ':' + inputs[k].getAttribute('name');
-                                                               var hidden = 
jQuery( document.createElement( 'input' ) );
-                                                               hidden.attr( 
'name', key );
-                                                               hidden.attr( 
'type', 'hidden' );
-                                                               hidden.val( 
multi );
-                                                               jQuery( 
'#editform' ).append( hidden );
+                                                               var input = 
jQuery( inputs[k] );
+                                                               if( 
input.attr('type') != 'checkbox' || input.attr('checked') ) {
+                                                                       var 
multi = input.val();
+                                                                       if( 
typeof( multi ) == 'object' ) multi = multi.join('\\n');
+                                                                       var key 
= type + ':' + inputs[k].getAttribute('name');
+                                                                       var 
hidden = jQuery( document.createElement( 'input' ) );
+                                                                       
hidden.attr( 'name', key );
+                                                                       
hidden.attr( 'type', 'hidden' );
+                                                                       
hidden.val( multi );
+                                                                       jQuery( 
'#editform' ).append( hidden );
+                                                               }
                                                        }
                                                }
                                        }
@@ -149,8 +152,6 @@
 
                # Organise the posted record data
                $data = array();
-#print_r($_REQUEST);
-#die;
                foreach( $_REQUEST as $key => $value ) {
                        if( preg_match( "|(.+):ra_(.+)|", $key, $m ) ) {
                                if( is_array( $value ) ) $value = join( "\n", 
$value );


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to