【问题标题】:inserting doctrine form data to database in symfony 1.4在 symfony 1.4 中将教义表单数据插入数据库
【发布时间】:2015-04-14 13:22:20
【问题描述】:

我正在尝试将数据插入 MySQL 数据库。

这是我的表单,在 action.class.php $this->formTodo = new LpTodoGeneralForm();

而 LpTodoGeneralForm.class.php 是:

<?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';
    }  
}

在提交表单时,我在 action.class.php 中获取帖子数据。 我的挑战是如何将这些数据插入到数据库中。

【问题讨论】:

标签: php doctrine symfony-1.4


【解决方案1】:

rb vishnu 的最后一条评论的链接已失效。

1ed 是正确的。

一旦为截止日期创建了验证器,表单就会插入数据。

“额外的表单域”在 symfony 1.4 表单中是一个很常见的问题。

【讨论】:

    猜你喜欢
    • 2014-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    相关资源
    最近更新 更多