email
Zend Formsでタイプの入力を作成しようとしていますが、目的の結果を得ることができません。
カスタムクラスを作成しました:
namespace AAA\Forms\Elements;
class Email extends \Zend_Form_Element_Text
{
function __construct($name, $label, $required)
{
parent::__construct($name);
$this->setAttrib('type', 'email');
$this->setLabel($label)->setRequired($required);
}
}
そして、私はそれを次のように使用しています:
class Application_Form_Register extends Zend_Form
{
public function init()
{
// …
$email = new AAA\Forms\Elements\Email('email', 'E-mail:', true);
$this->addElement($email);
// …
}
}
そして私が得るものは:
<input type="text" name="email" id="email" value="" type="email">
type
2つのパラメーターに注意してください。
( Bootstrap.phpで) HTML5 doctypeを設定し$documentType = new Zend_View_Helper_Doctype(); $documentType->doctype('HTML5');
、これも試しました。
function __construct($name, $label, $required)
{
$options = array();
$options['type'] = 'email';
parent::__construct($name, $options);
// …
}
Zend HTML5 Form要素タイプを読みましたが、どの答えも機能しません。グリッチライブラリも試しましたが、結果は同じです。
Zend FrameworkにHTML5フォームコントロールを使用させる方法を知っている人はいますか?