Permalink
Browse files

Merge pull request #1169 from vietvh/labelclass

Set the CSS class for JForm field label
  • Loading branch information...
2 parents 7f7d459 + 71d5239 commit 18070ddd9e431b03018473b985bc3a8f28efa105 @LouisLandry LouisLandry committed Apr 26, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 libraries/joomla/form/field.php
@@ -166,6 +166,14 @@
protected $value;
/**
+ * The label's CSS class of the form field
+ *
+ * @var mixed
+ * @since 11.1
+ */
+ protected $labelClass;
+
+ /**
* The count value for generated name field
*
* @var integer
@@ -236,6 +244,7 @@ public function __get($name)
case 'type':
case 'validate':
case 'value':
+ case 'labelClass':
case 'fieldname':
case 'group':
return $this->$name;
@@ -371,6 +380,9 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
// Set the field default value.
$this->value = $value;
+ // Set the CSS class of field label
+ $this->labelClass = (string) $element['labelclass'];
+
return true;
}
@@ -483,6 +495,7 @@ protected function getLabel()
// Build the class for the label.
$class = !empty($this->description) ? 'hasTip' : '';
$class = $this->required == true ? $class . ' required' : $class;
+ $class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class;
// Add the opening label tag and main attributes attributes.
$label .= '<label id="' . $this->id . '-lbl" for="' . $this->id . '" class="' . $class . '"';

0 comments on commit 18070dd

Please sign in to comment.