简体   繁体   中英

inserting doctrine form data to database in symfony 1.4

I am trying to insert data into a MySQL database.

Here is my form, in action.class.php $this->formTodo = new LpTodoGeneralForm();

and the LpTodoGeneralForm.class.php is:

<?php

class LpTodoGeneralForm extends BaseFormDoctrine{
    public function configure(){      
        $this->widgetSchema['deadline_date'] = new sfWidgetFormInputText(array(), array('class' => 'input-text small datepicker', 'readonly' => 'readonly'));
        $this->widgetSchema['firm_name'] = new sfWidgetFormInputText(array(), array('class' => 'input-text datepicker'));
        $this->validatorSchema['todo_by'] = new sfValidatorPass(array('required' => true));
        $this->widgetSchema['todo_by'] = new sfWidgetFormInputText(array(), array('class' => 'input-text small datepicker', 'readonly' => 'readonly'));
    }

    public function setup(){
        $this->setWidgets(array(
            'done'              => new sfWidgetFormInputCheckbox(),
            'deadline'          => new sfWidgetFormInputCheckbox(),
            'deadline_date'         => new sfWidgetFormInputText(),
            'firm_name'         => new sfWidgetFormInputText(),
            'description'       => new sfWidgetFormTextarea(),
            'todo_by'         => new sfWidgetFormInputText(),
        ));

        $this->widgetSchema->setNameFormat('todo[%s]');
        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
        $this->setupInheritance();

        parent::setup();
    }

    public function getModelName(){
        return 'Todo';
    }  
}

While submitting the form I am getting the post data in action.class.php. My challenge is how to insert this data into the database.

the link is dead for rb vishnu's last comment.

and 1ed is correct.

The form will insert the data once the validator for deadline_date is created.

the "extra form field" is a pretty common issue in symfony 1.4 forms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM