-- Tobias Gies <[EMAIL PROTECTED]> wrote
(on Monday, 03 March 2008, 08:22 PM +0100):
> Maybe you can help me with my problem. I have created my basic login
> form object like this:
>
> Pts/Form/User/Login.php:
>
> <?php
> /**
> * Zend_Form
> */
> require_once 'Zend/Form.php';
>
> class Pts_Form_User_Login extends Zend_Form {
> public function __construct($options = array()) {
> parent::__construct($options);
> $this->addElement('text',
> 'username',
> array('label' => 'Username:',
> 'required' => true,
> 'validators' => array(array('NotEmpty',
> true),
> array('Regex',
> false,
> '/^[a-z0-9_-]$/i'))))
Your problem is here -- the third argument should be in an array:
array('Regex', false, array('/^[a-z0-9_-]$/i'))
That said, I should probably ensure that I pass an array to the
reflection object; I've marked this in the tracker:
http://framework.zend.com/issues/browse/ZF-2786
> ->addElement('password',
> 'password',
> array('label' => 'Password:',
> 'required' => true,
> 'validators' => array('NotEmpty')))
> ->addElement('submit',
> 'submit',
> array('label' => 'Send'));
> }
> }
>
> And I am calling it like this in my action controller (I'm currently
> only testing Zend_Form, so no processing code in there just yet):
>
> public function loginAction() {
> require_once 'Pts/Form/User/Login.php';
> $form = new Pts_Form_User_Login();
> $view = $this->initView();
> $view->form = $form->render();
> }
>
> The following error occurs:
> Catchable fatal error: Argument 1 passed to
> ReflectionClass::newInstanceArgs() must be an array, string given,
> called in
> /var/www/premium-ts-redesign/application/library/Zend/Form/Element.php
> on line 972 and defined in
> /var/www/premium-ts-redesign/application/library/Zend/Form/Element.php
> on line 915
>
> I have xdebug running here, so I uploaded the full output of the code
> including the backtraces for you:
> http://stalker.akinos.de/xdebug-output.html
>
> Best regards and thanks in advance for your help,
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/