Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Set the CSS class for JForm field label #1169

Merged
merged 3 commits into from

2 participants

@vietvh

This pull is intended to allow developer to set CSS class for form field's label. It can be useful for styling purpose.

For example Twitter Bootstrap requires class="control-label" for form field label tag.

Usage: add labelclass="your-css-class" in your form xml manifest

<......description="" required="true" labelclass="control-label" />

@LouisLandry

Just a few code style issues to clean up and we can get this merged. Thanks!

http://developer.joomla.org/pulls/pulls/1169.html

@vietvh

Just fixed some tab issues.

@LouisLandry LouisLandry merged commit 18070dd into joomla:staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 23, 2012
  1. @vietvh
Commits on Apr 26, 2012
  1. @vietvh

    Fixed some tab issues

    vietvh authored
  2. @vietvh
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +13 −0 libraries/joomla/form/field.php
View
13 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 . '"';
Something went wrong with that request. Please try again.