【问题标题】:MVCForm Agile Toolkit Form Update Record ID must be specified必须指定 MVCForm Agile Toolkit 表单更新记录 ID
【发布时间】:2012-09-03 23:25:13
【问题描述】:

希望是有关 Agle Toolkit 的简单问题。目前使用以下代码获取

AJAX 响应错误:SyntaxError: Unexpected token

基本异常

必须指定记录 ID,否则使用 loadAny()

页面\grant.php

<?php
class page_grant extends Page {
    function init(){
        parent::init();

        $saveForm=$this->add('MVCForm');
        $model=$this->add('Model_Grant')->load($_GET['id']);
        $saveForm->setModel($model);

        $saveForm->addSubmit();

        $saveForm->onSubmit(function($saveForm){
            $saveForm->update()->js()->univ()->successMessage('Grant info saved.')->execute();
        });
    }
}

和 Model_Grant:

<?php

class Model_Grant extends Model_Table {
    public $table='minigrant';

    function init() {
        parent::init();
        $this->addField('grant_number');
        $this->addField('grant_name');
        $this->addField('uid');
    }
}

数据加载正常,但无法按照上述错误消息将其保存回来。

【问题讨论】:

    标签: frameworks atk4 php agiletoolkit


    【解决方案1】:

    您必须将stickyGET添加到id字段:

    <?php
    class page_grant extends Page {
        function init(){
            parent::init();
    
            $this->api->stickyGET('id');
    
            $saveForm=$this->add('MVCForm');
            $model=$this->add('Model_Grant')->load($_GET['id']);
            $saveForm->setModel($model);
    
            $saveForm->addSubmit();
    
            $saveForm->onSubmit(function($saveForm){
                $saveForm->update()->js()->univ()->successMessage('Grant info saved.')->execute();
            });
        }
    }
    

    找到以下数据: http://agiletoolkit.org/learn/tutorial/jobeet/day8

    Agile Toolkit 确实需要一个包含更多此类示例的文档源,因为它很容易在我使用过的最佳框架上使用。

    如果他们 (@romaninsh) 可以更好地编写文档,那么我认为它会做得更好。我想他们可能也需要从 AGPL 更改许可证,但这对我个人而言并不重要,因为我正在研究 OSS。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-17
      • 2023-03-06
      • 1970-01-01
      • 2017-04-08
      • 1970-01-01
      • 1970-01-01
      • 2018-11-19
      • 1970-01-01
      相关资源
      最近更新 更多