Permalink
Browse files

created new option called labelDefaults instead of using inputDefaults

  • Loading branch information...
1 parent c4208a6 commit f9e28880df01484af3b3689ca1746d85517a0e5e @nabeelio committed Apr 5, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 lib/Cake/View/Helper/FormHelper.php
@@ -80,6 +80,13 @@ class FormHelper extends AppHelper {
protected $_inputDefaults = array();
/**
+ * Persistent default options used by label(). Set by FormHelper::create().
+ *
+ * @var array
+ */
+ protected $_labelDefaults = array();
+
+/**
* An array of field names that have been excluded from
* the Token hash used by SecurityComponent's validatePost method
*
@@ -381,10 +388,13 @@ public function create($model = null, $options = array()) {
'url' => null,
'default' => true,
'encoding' => strtolower(Configure::read('App.encoding')),
- 'inputDefaults' => array()),
+ 'inputDefaults' => array(),
+ 'labelDefaults' => array()),
$options);
$this->_inputDefaults = $options['inputDefaults'];
+ $this->_labelDefaults = $options['labelDefaults'];
unset($options['inputDefaults']);
+ unset($options['labelDefaults']);
if (!isset($options['id'])) {
$domId = isset($options['action']) ? $options['action'] : $this->request['action'];
@@ -824,11 +834,11 @@ public function label($fieldName = null, $text = null, $options = array()) {
$options = array('class' => $options);
}
- if(isset($this->_inputDefaults['label'])) {
- if(is_string($this->_inputDefaults['label']) && !isset($options['class'])) {
- $options['class'] = $this->_inputDefaults['label'];
+ if(isset($this->_labelDefaults)) {
+ if(is_string($this->_labelDefaults) && !isset($options['class'])) {
+ $options['class'] = $this->_labelDefaults;
} else {
- $options = array_merge($this->_inputDefaults['label'], $options);
+ $options = array_merge($this->_labelDefaults, $options);
}
}

0 comments on commit f9e2888

Please sign in to comment.