开发者

Is there a datetime control for the Zend framework?

Here I have a password field:

/*********************PASSWORD**********************/
        $password = new Zend_Form_Element_Password('password');
        $alnumValidator = new Zend_Validate_Alnum();


        $password   ->setRequired(true)
                    ->setLabel('Password:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
             开发者_开发问答       ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($password);

It automatically makes the control use stars instead of actual letters. Is there a date control somewhere in the Zend framework?


There is no DateTime element in the regular Zend_Form package. DateTime is not a standard HTML form element. However, the Zend_Dojo Form Elements, do have a DateTime element that provides a calendar drop-down for selecting a date, as well as client-side date validation and formatting:

  $form->addElement(
      'DateTextBox',
      'foo',
      array(
          'label'          => 'Date:',
          'required'       => true,
          'invalidMessage' => 'Invalid date specified.',
          'formatLength'   => 'long',
      )
  );

Refer to the reference guide on how to enable Dojo in your Zend Framework project.

There is also a DateTime element in the ZendX_JQuery package, but that's part of the Extras package and not of the standard ZF distribution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜