Issues

ZF-10564: Zend_View_Helper_FormText HTML5 Improvement

Issue Type: Patch Created: 2010-10-16T08:29:28.000+0000 Last Updated: 2012-11-20T21:38:05.000+0000 Status: Open Fix version(s): Reporter: Andrius Putna (andrius.putna) Assignee: None Tags: - Zend_View

Related issues: Attachments:

Description

Some of HTML5 features can be used today without worrying about browser support. One of these things is More info at http://diveintohtml5.org/forms.html

All I wanted to achieve is to have element The first thing came to my mind is to do like this:

$e = new Zend_Form_Element_Text('email'); $e->setAttrib('type', 'email');

Zend_View_Helper_FormText still renders it as May be a better way is to have all these new helpers Zend_View_Helper_FormEmail, Zend_View_Helper_FormDate, Zend_View_Helper_FormRange ... But lests consider the following patch for Zend_View_Helper_FormText:

Index: .

--- . (revision 664) +++ . (working copy) @@ -71,7 +71,9 @@ $endTag= '>'; }

  • $xhtml = '<input type="text"'
  • $type = $this->_getType($attribs);
  • $xhtml = '<input type="' . $type . '"' . ' name="' . $this->view->escape($name) . '"' . ' id="' . $this->view->escape($id) . '"' . ' value="' . $this->view->escape($value) . '"'

@@ -81,4 +83,29 @@

 return $xhtml;

}

  • private function _getType(array $attribs)
  • {
  • if(array_key_exists('type', $attribs)) {
  • $allowed = array(
  • 'email',
  • 'number',
  • 'url',
  • 'range',
  • 'search',
  • 'color',
  • 'date',
  • 'week',
  • 'month',
  • 'time',
  • 'datetime',
  • 'datetime-local',
  • );
  • if(in_array($attribs['type'], $allowed)) {
  • return $attribs['type'];
  • }
  • }
  • return 'text';
  • } }

Comments

Posted by Simon (_sims_) on 2010-11-20T22:47:59.000+0000

I'd recommend not having any restraint until ZF has full support for HTML5.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts