0

バリデーター + フィルターで zend ビューヘルパーフォームをどのように使用すればよいですか?

http://framework.zend.com/manual/en/zend.view.helpers.htmlからのバリデーター + フィルターが欠落している

<form action="action.php" method="post">
 <p>
  <label>Your Email:
   <?php echo $this->formText('email', 'you@example.com', array('size' => 32)) ?>
  </label>
 </p>
 <p>
  <label>Your Country:    
   <?php echo $this->formSelect('country', 'us', null, $this->countries) ?>    
  </label>
 </p>
 <p>
  <label>Would you like to opt in?
   <?php echo $this->formCheckbox('opt_in', 'yes', null, array('yes', 'no')) ?>
  </label>
 </p>
</form>

ありがとう、

4

1 に答える 1

0

フォームを別のクラスとして作成すると、必要なすべてのバリデーターとフィルターを使用できます。ドキュメントに完全なセットアップ情報があります:

http://framework.zend.com/manual/en/zend.form.quickstart.html

ドキュメントの例:

$form = new Zend_Form();
$form->setAction('/user/login')
     ->setMethod('post');

// Create and configure username element:
$username = $form->createElement('text', 'username');
$username->addValidator('alnum')
         ->addValidator('regex', false, array('/^[a-z]+/'))
         ->addValidator('stringLength', false, array(6, 20))
         ->setRequired(true)
         ->addFilter('StringToLower');

// Create and configure password element:
$password = $form->createElement('password', 'password');
$password->addValidator('StringLength', false, array(6))
         ->setRequired(true);

// Add elements to form:
$form->addElement($username)
     ->addElement($password)
     // use addElement() as a factory to create 'Login' button:
     ->addElement('submit', 'login', array('label' => 'Login'));
于 2010-07-06T12:10:31.520 に答える