通过CMS从表单存储内容时出现问题

时间:2010-07-02 20:22:25

标签: php javascript mysql forms post

我有一个名为sales的MySQL表,其中包含产品,数量和付费字段。

我正在使用类似CMS的系统,它具有自定义的表单方式和自定义表单字段。

据我所知,给予表单字段的id是用作要插入的表名的内容。

我目前使用的表格如下:

<?php

    include("../../include/session.php");
    include("include/tables.php");
    include("include/fields.php");

    //if you need to ovveride the phpbmsTable class make sure to include the modules file
    include("include/sales.php");

    if(!isset($_GET["backurl"]))
        $backurl = NULL;
    else{
        $backurl = $_GET["backurl"];
        if(isset($_GET["refid"]))
            $backurl .= "?refid=".$_GET["refid"];
    }

    $thetable = new sales($db, "tbld:490cf2d1-1c72-7b99-461d-b1b8e68553c4");
    $therecord = $thetable->processAddEditPage();

    if(isset($therecord["phpbmsStatus"]))
        $statusmessage = $therecord["phpbmsStatus"];

    $pageTitle = "Sales";


    $phpbms->cssIncludes[] = "pages/menus.css";
    $phpbms->jsIncludes[] = "modules/base/javascript/menu.js";

        $theform = new phpbmsForm();

        $theinput = new inputSmartSearch($db, "product", "Choose Product",$therecord["product"], "Choose Product", TRUE, NULL, NULL, TRUE, $required=true);
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $theinput = new inputField("quantity",$therecord["quantity"],"Quantity",true, NULL, 1);
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $theinput = new inputCheckbox("paid", $therecord["paid"], "Paid");
        $theform->addField($theinput);

        $thetable->getCustomFieldInfo();
        $theform->prepCustomFields($db, $thetable->customFieldsQueryResult, $therecord);
        $theform->jsMerge();

    include("header.php");

?><div class="bodyline">

    <?php $theform->startForm($pageTitle)?>

    <div id="leftSideDiv">
        <fieldset>
            <legend><label for="S">Sales</label></legend>

            <p class="big"><?php $theform->showField("product"); ?></p>
            <p class="big"><?php $theform->showField("quantity"); ?></p>
            <p class="big"><?php $theform->showField("paid"); ?></p>

        </fieldset>
    </div>
    <?php

        $theform->showGeneralInfo($phpbms,$therecord);
        $theform->endForm();
    ?>
</div>
<?php include("footer.php");?>

数量和付费的内容在没有问题的情况下存储在表中,但产品没有,我可以告诉,因为在某些时候'ds-'被添加到id之前。我想这是因为我使用的是不同的输入字段(我需要使用它)。

这是尝试保存表单后POST的结果:

数组([product] =&gt; 75c72a6a-83d9-11df-951a-fa9c1ec271f2 [ds-product] =&gt;电晕[数量] =&gt; 2 [付费] =&gt; 0 [createdby] =&gt; [ creationdate] =&gt; [command] =&gt;保存[modifiedby] =&gt; [cancelclick] =&gt; 0 [modifieddate] =&gt; [uuid] =&gt;:4402add3-b884-43e6-04ad-c76d92ee465b [id] =&gt;)

相反,UUID会插入到产品中,而不是产品名称。

我想知道是否有任何解决方案?我不认为我可以直接访问更改查询代码,并且我无法将产品重命名为ds-product,因为我无法更改查询以访问带连字符的字段名。

有可能覆盖类,如上所述我已经包含了sales.php,它基于样本here

解决方案是否以某种方式覆盖了insertRecord函数,如果是,如何?或者是否有更简单的解决方案?

1 个答案:

答案 0 :(得分:0)

您可以更改数组中项目的值,以便始终可以将产品项覆盖为要进入该字段的值。虽然我会说,如果该字段期望看起来像一个id值,并且你设置为字符串,那么这将不会很好。