Form is trying to save the login value of the submit button to my DB.

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-03-07T14:43:43Z Indexed on 2010/03/08 9:06 UTC
Read the original article Hit count: 314

Filed under:
|
|
|

Here's my Zend code:

<?php

require_once ('Zend\Form.php');

class Sergio_Form_registrationform extends Zend_Form {
    public function init(){     
        /*********************USERNAME**********************/
        $username = new Zend_Form_Element_Text('username');
        $alnumValidator = new Zend_Validate_Alnum();

        $username   ->setRequired(true)
                    ->setLabel('Username:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($username);

        /*********************EMAIL**********************/
        $email = new Zend_Form_Element_Text('email');
        $alnumValidator = new Zend_Validate_Alnum();


        $email      ->setRequired(true)
                    ->setLabel('EMail:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($email);

        /*********************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);

        /*********************NAME**********************/
        $name = new Zend_Form_Element_Text('name');
        $alnumValidator = new Zend_Validate_Alnum();


        $name       ->setRequired(true)
                    ->setLabel('Name:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($name);

        /*********************LASTNAME**********************/
        $lastname = new Zend_Form_Element_Text('lastname');
        $alnumValidator = new Zend_Validate_Alnum();


        $lastname   ->setRequired(true)
                    ->setLabel('Last Name:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($lastname);

        /*********************DATEOFBIRTH**********************/
        $dateofbirth = new Zend_Form_Element_Text('dateofbirth');
        $alnumValidator = new Zend_Validate_Alnum();


        $dateofbirth->setRequired(true)
                    ->setLabel('Date of Birth:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($dateofbirth);

        /*********************AVATAR**********************/
        $avatar = new Zend_Form_Element_File('avatar');
        $alnumValidator = new Zend_Validate_Alnum();


        $avatar     ->setRequired(true)
                    ->setLabel('Please select a display picture:');
        $this->addElement($avatar);

        /*********************SUBMIT**********************/

        $this->addElement('submit', 'login', array('label' => 'Login'));
    }
}
?>

Here's the code I use to save the values:

public function saveforminformationAction(){
        $form = new Sergio_Form_registrationform();
        $request = $this->getRequest();

        //if($request->isPost() && $form->isValid($_POST)){         
            $data = $form->getValues();
            $db = $this->_getParam('db');

            $db->insert('user',$data);          
        //}     
    }

When trying to save the values, I recieve a ghastly error:

Column 'login' not found.

© Stack Overflow or respective owner

Related posts about php

Related posts about zend-form