Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added setRequired method to automatically add an html5 required attribute #28

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+11 −0
Split
View
@@ -117,6 +117,17 @@ public function isAutoloadFilters()
{
return $this->_autoloadFilters;
}
+
+ /**
+ * Overrides the parent setRequired() method to add the required attribute to HTML5 forms for $flag === TRUE
+ * (non-PHPdoc)
+ * @see Zend_Form_Element::setRequired()
+ */
+ public function setRequired($flag) {
+ if ($flag === TRUE && $this->_isHtml5())
+ $this->setAttrib('required', 'required');
+ return parent::setRequired($flag);
+ }
/**
* Check if the doctype is HTML5