r82184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82183‎ | r82184 | r82185 >
Date:19:43, 15 February 2011
Author:kipcool
Status:deferred
Tags:
Comment:
solved problem with disabled checkboxes
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/forms.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/forms.php
@@ -13,7 +13,7 @@
1414
1515 function getTextArea( $name, $text = "", $rows = 5, $columns = 80, $disabled = false ) {
1616 if ( $disabled ) {
17 - return '<textarea disabled="disabled" name="' . $name . '" rows="' . $rows . '" cols="' . $columns . '">' . htmlspecialchars( $text ) . '</textarea>';
 17+ return '<textarea name="' . $name . '" rows="' . $rows . '" cols="' . $columns . '" READONLY>' . htmlspecialchars( $text ) . '</textarea>';
1818 } else {
1919 return '<textarea name="' . $name . '" rows="' . $rows . '" cols="' . $columns . '">' . htmlspecialchars( $text ) . '</textarea>';
2020 }
@@ -27,11 +27,10 @@
2828 }
2929
3030 function getCheckBox( $name, $isChecked, $disabled = false ) {
31 -// FIXME: if disabled is activated, then the page cannot be saved... why?
32 -// this affects identical_meaning checkboxes, but not delete_checkboxes
33 -// workaround : disable the checkbox with java instead of html "disabled"
 31+ // a disabled checkbox returns no value, as if unchecked
 32+ // therefore the value of a disabled, but checked, checkbox must be sent with a hidden input
3433 if ( $disabled ) {
35 - return '<input type="checkbox" name="' . $name . '"' . checkBoxCheckAttribute( $isChecked ) . ' onClick="this.checked = ! this.checked ;"/>';
 34+ return '<input disabled="disabled" type="checkbox" name="' . $name . checkBoxCheckAttribute( $isChecked ) . '/><input type="hidden" name="' . $name . '" value="' . $isChecked . '"/>';
3635 } else {
3736 return '<input type="checkbox" name="' . $name . '"' . checkBoxCheckAttribute( $isChecked ) . '/>';
3837 }
@@ -39,7 +38,7 @@
4039
4140 function getCheckBoxWithOnClick( $name, $isChecked, $onClick, $disabled = false ) {
4241 if ( $disabled ) {
43 - return '<input disabled="disabled" type="checkbox" name="' . $name . '"' . checkBoxCheckAttribute( $isChecked ) . ' onclick="' . $onClick . '"/>';
 42+ return '<input disabled="disabled" type="checkbox" name="' . $name . '"' . checkBoxCheckAttribute( $isChecked ) . '"/><input type="hidden" name="' . $name . '" value="' . $isChecked . '"/>';
4443 } else {
4544 return '<input type="checkbox" name="' . $name . '"' . checkBoxCheckAttribute( $isChecked ) . ' onclick="' . $onClick . '"/>';
4645 }

Status & tagging log