Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Set the CSS class for JForm field label
Browse files Browse the repository at this point in the history
  • Loading branch information
vietvh committed Apr 23, 2012
1 parent 40d7a23 commit 6dcabc7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libraries/joomla/form/field.php
Expand Up @@ -165,6 +165,14 @@ abstract class JFormField
*/
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
*
Expand Down Expand Up @@ -236,6 +244,7 @@ public function __get($name)
case 'type':
case 'validate':
case 'value':
case 'labelClass':
case 'fieldname':
case 'group':
return $this->$name;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 . '"';
Expand Down

0 comments on commit 6dcabc7

Please sign in to comment.