Req #10191 [Opn->Asn]: [patch] add disabled/class methods to HTML_QuickForm_element
| From: | borz_off at cs dot msu dot su | Date: | Sat, 26 Sep 2009 10:15:24 +0000 |
| Subject: | Req #10191 [Opn->Asn]: [patch] add disabled/class methods to HTML_QuickForm_element | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-1733@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=10191&edit=1
ID: 10191
Updated by: borz_off@cs.msu.su
Reported By: greg at mtechsolutions dot ca
Summary: [patch] add disabled/class methods to
HTML_QuickForm_element
-Status: Open
+Status: Assigned
Type: Feature/Change Request
-Package: HTML_QuickForm2
+Package: HTML_Common2
PHP Version: Irrelevant
-Assigned To:
+Assigned To: avb
Roadmap Versions:
New Comment:
-Status: Open
+Status: Assigned
-Package: HTML_QuickForm2
+Package: HTML_Common2
-Assigned To:
+Assigned To: avb
I will add addClass(), removeClass() and hasClass() to HTML_Common2,
the other stuff is not that useful.
Previous Comments:
------------------------------------------------------------------------
[2007-02-26 15:11:56] avb
Moving feature request to HTML_QuickForm2 package.
I doubt we'll ever implement setDisabled() / getDisabled(), we are
trying to get rid of bloated APIs, but methods for working with 'class'
attribute may be interesting, considering microformats and such.
------------------------------------------------------------------------
[2007-02-26 10:38:18] greg at mtechsolutions dot ca
Description:
------------
This adds setDisabled(), getDisabled(), setClass(), getClass(),
addClass(), removeClass() to the element object.
(originally available at http://freepbx.org/trac/changeset/3813)
Test script:
---------------
Index:
/freepbx/branches/quickform/amp_conf/htdocs/admin/common/HTML/QuickForm/element.php
===================================================================
---
/freepbx/branches/quickform/amp_conf/htdocs/admin/common/HTML/QuickForm/element.php
(revision 3578)
+++
/freepbx/branches/quickform/amp_conf/htdocs/admin/common/HTML/QuickForm/element.php
(revision 3813)
@@ -316,4 +316,122 @@
return $this->_label;
} //end func getLabel
+
+ // }}}
+ // {{{ setDisabled()
+ /**
+ * Sets whether an input is disabled
+ *
+ * @param bool $disabled Whether the field is disabled or
not
+ * @since 1.0
+ * @access public
+ * @return void
+ */
+ function setDisabled($disabled)
+ {
+ if (!$disabled) {
+ $this->removeAttribute('disabled');
+ } else {
+ $this->updateAttributes(array('disabled'=>'disabled'));
+ }
+ } //end func setDisabled
+
+ // }}}
+ // {{{ getDisabled()
+ /**
+ * Gets whether an input is disabled
+ *
+ * @param bool $disabled Whether the field is disabled or
not
+ * @since 1.0
+ * @access public
+ * @return void
+ */
+ function getDisabled($disabled)
+ {
+ return $this->getAttribute('disabled');
+ } //end func getDisabled
+
+ // }}}
+ // {{{ setClass()
+ /**
+ * Sets the class
+ *
+ * @param mixed $class A string or array indicating the
class(es) to set
+ * @since 1.0
+ * @access public
+ * @return void
+ */
+ function setClass($class)
+ {
+ if (is_array($class)) {
+ $class = implode(' ',$class);
+ }
+ $this->updateAttributes(array('class'=>$class));
+ } //end func setClass
+
+ // }}}
+ // {{{ addClass()
+ /**
+ * Sets whether a checkbox is disabled
+ *
+ * @param bool $disabled Whether the field is disabled or
not
+ * @since 1.0
+ * @access public
+ * @return void
+ */
+ function addClass($class)
+ {
+ if (!is_array($class)) {
+ $class = array($class);
+ }
+
+ $curclass = $this->getClass();
+ foreach ($class as $c) {
+ if (!in_array($c, $curclass)) {
+ $curclass[] = $c;
+ }
+ }
+ $this->setClass($class);
+ } //end func addClass
+
+ // }}}
+ // {{{ removeClass()
+ /**
+ * Sets whether a checkbox is disabled
+ *
+ * @param bool $disabled Whether the field is disabled or
not
+ * @since 1.0
+ * @access public
+ * @return void
+ */
+ function removeClass($class)
+ {
+ if (!is_array($class)) {
+ $class = array($class);
+ }
+
+ $curclass = $this->getClass();
+ foreach ($class as $c) {
+ if (in_array($c, $curclass)) {
+ $idx = array_search($c, $curclass);
+ unset($curclass[$idx]);
+ }
+ }
+ $this->setClass($class);
+ } //end func removeClass
+
+ // }}}
+
+ // {{{ getClass()
+ /**
+ * Sets whether a checkbox is disabled
+ *
+ * @since 1.0
+ * @access public
+ * @return array
+ */
+ function getClass()
+ {
+ return explode(' ',$this->getAttribute('class'));
+ } //end func getClass
// }}}
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=10191&edit=1