From f8151c1594c2148e99ddd96bc7e06c892fb38a5a Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sat, 13 Mar 2010 14:59:44 +0000 Subject: [PATCH] Apply CSS classes for XML checkboxes/radiobuttons to their labels as well. --- includes/Xml.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/Xml.php b/includes/Xml.php index 464b142c05..cf3f2ab372 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -336,11 +336,16 @@ class Xml { /** * Convenience function to build an HTML form label * @param $label text of the label - * @param $id + * @param $id + * @param $attrs Array, other attributes * @return string HTML */ - public static function label( $label, $id ) { - return self::element( 'label', array( 'for' => $id ), $label ); + public static function label( $label, $id, $attribs=array() ) { + $a = array( 'for' => $id ); + if( isset( $attribs['class'] ) ){ + $a['class'] = $attribs['class']; + } + return self::element( 'label', $a, $label ); } /** @@ -363,7 +368,7 @@ class Xml { */ public static function inputLabelSep( $label, $name, $id, $size=false, $value=false, $attribs=array() ) { return array( - Xml::label( $label, $id ), + Xml::label( $label, $id, $attribs ), self::input( $name, $size, $value, array( 'id' => $id ) + $attribs ) ); } @@ -375,7 +380,7 @@ class Xml { public static function checkLabel( $label, $name, $id, $checked=false, $attribs=array() ) { return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) . ' ' . - self::label( $label, $id ); + self::label( $label, $id, $attribs ); } /** @@ -385,7 +390,7 @@ class Xml { public static function radioLabel( $label, $name, $value, $id, $checked=false, $attribs=array() ) { return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) . ' ' . - self::label( $label, $id ); + self::label( $label, $id, $attribs ); } /** -- 2.20.1