From e754dfaf4d8c8271595f89aa70d5b6f648d5c427 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Sat, 7 Feb 2015 08:55:58 -0500 Subject: [PATCH] HTMLForm: Support hide-if for HTMLCheckMatrix It outputs multiple table rows, and each one needs the class and data attribute. Change-Id: I6667c3ea0e10167d941cb214d76889b389af79a3 --- includes/htmlform/HTMLCheckMatrix.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/htmlform/HTMLCheckMatrix.php b/includes/htmlform/HTMLCheckMatrix.php index 6c538fdd15..83f126657f 100644 --- a/includes/htmlform/HTMLCheckMatrix.php +++ b/includes/htmlform/HTMLCheckMatrix.php @@ -178,6 +178,13 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { $helptext = $this->getHelpTextHtmlTable( $this->getHelpText() ); $cellAttributes = array( 'colspan' => 2 ); + $hideClass = ''; + $hideAttributes = array(); + if ( $this->mHideIf ) { + $hideAttributes['data-hide-if'] = FormatJson::encode( $this->mHideIf ); + $hideClass = 'mw-htmlform-hide-if'; + } + $label = $this->getLabelHtml( $cellAttributes ); $field = Html::rawElement( @@ -186,9 +193,12 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { $inputHtml . "\n$errors" ); - $html = Html::rawElement( 'tr', array( 'class' => 'mw-htmlform-vertical-label' ), $label ); + $html = Html::rawElement( 'tr', + array( 'class' => "mw-htmlform-vertical-label $hideClass" ) + $hideAttributes, + $label ); $html .= Html::rawElement( 'tr', - array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass" ), + array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass $hideClass" ) + + $hideAttributes, $field ); return $html . $helptext; -- 2.20.1