r89723 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89722‎ | r89723 | r89724 >
Date:09:57, 8 June 2011
Author:nad
Status:deferred (Comments)
Tags:
Comment:
bug fix: multiselects not working from edit view
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin.php (modified) (history)
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -110,27 +110,28 @@
111111 # JS to add an onSubmit method that adds the record forms contents to hidden values in the edit form
112112 $wgOut->addScript( "<script type='$wgJsMimeType'>
113113 function raRecordForms() {
114 - forms = [ $jsFormsList ];
 114+ var forms = [ $jsFormsList ];
115115 for( i = 0; i < forms.length; i++ ) {
116 - type = forms[i];
117 - form = document.getElementById( type + '-form' );
118 - tags = [ 'input', 'select', 'textarea' ];
 116+ var type = forms[i];
 117+ var form = document.getElementById( type + '-form' );
 118+ var tags = [ 'input', 'select', 'textarea' ];
119119 for( j = 0; j < tags.length; j++ ) {
120 - inputs = form.getElementsByTagName( tags[j] );
 120+ var inputs = form.getElementsByTagName( tags[j] );
121121 for( k = 0; k < inputs.length; k++ ) {
122 - input = inputs[k];
123 - key = type + ':' + input.getAttribute('name');
124 - hidden = document.createElement( 'input' );
125 - hidden.setAttribute( 'name', key );
126 - hidden.setAttribute( 'type', 'hidden' );
127 - hidden.value = input.value;
128 - document.getElementById( 'editform' ).appendChild( hidden );
 122+ var multi = jQuery( inputs[k] ).val();
 123+ if( typeof( multi ) == 'object' ) multi = multi.join('\\n');
 124+ var key = type + ':' + inputs[k].getAttribute('name');
 125+ var hidden = jQuery( document.createElement( 'input' ) );
 126+ hidden.attr( 'name', key );
 127+ hidden.attr( 'type', 'hidden' );
 128+ hidden.val( multi );
 129+ jQuery( '#editform' ).append( hidden );
129130 }
130131 }
131132 }
132133 }
133134 function raAddToSubmit() {
134 - document.getElementById( 'editform' ).setAttribute( 'onsubmit', 'raRecordForms()' );
 135+ jQuery( '#editform' ).attr( 'onsubmit', 'raRecordForms()' );
135136 }
136137 addOnloadHook( raAddToSubmit );
137138 </script>" );
@@ -148,6 +149,8 @@
149150
150151 # Organise the posted record data
151152 $data = array();
 153+#print_r($_REQUEST);
 154+#die;
152155 foreach( $_REQUEST as $key => $value ) {
153156 if( preg_match( "|(.+):ra_(.+)|", $key, $m ) ) {
154157 if( is_array( $value ) ) $value = join( "\n", $value );
Index: trunk/extensions/RecordAdmin/RecordAdmin.php
@@ -10,7 +10,7 @@
1111 * @author Siebrand Mazeland
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
14 -define( 'RECORDADMIN_VERSION', '1.2.2, 2011-06-08' );
 14+define( 'RECORDADMIN_VERSION', '1.2.3, 2011-06-08' );
1515
1616 $dir = dirname( __FILE__ ) . '/';
1717 $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php';

Comments

#Comment by Nikerabbit (talk | contribs)   10:32, 8 June 2011

Forgot debugging statements?

Status & tagging log