繁体   English   中英

表单元素的内容未保存到数据库,而其他元素

[英]Content of form element not being saved to database while others are

我正在使用类似CMS的系统phpBMS,该系统定义了某种制作表格的方式,并定义了在此类表格中使用的表格元素。

是表单模板的示例,并且这些是定义的字段。

通常,这很简单。 如果您有一个id为“ name”的inputField,则该字段的内容将保存到分配表单的表的name字段中。

目前,我使用的是另一个输入字段inputSmartSearch,它的工作原理类似于google建议,因为它可以在您键入时搜索并自动显示结果。

我想使用该字段的内容进入“产品”表,但不确定如何设置。

我这样称呼我的smartsearch:

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

当我查看_POST返回的内容时,我看到:

数组([选择产品] => 75c72a6a-83d9-11df-951a-fa9c1ec271f2 [ds-选择产品] =>电晕[数量] => 2 [类型] =>现金)

我已经像这样设置了数量和类型字段

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

    $theinput = new inputBasicList("type",$therecord["paymenttype"],array("Cash"=>"cash","Credit"=>"credit"), "Payment Type");
    $theinput->setAttribute("class","important");
    $theform->addField($theinput);

type和quanitity字段的内容可以完美地插入数据库中,但是从smartsearch字段中绝对不会插入任何内容。

为什么? 我将如何开始对此进行故障排除?

我认为在这种情况下,您将需要手动将此值添加到持久化到数据库的数组中。 所以:

$ variables [“ product”] =您想要的值

所以,如果你圣。 要保留名称,请分配Ds-chooseproducts。 如果要保留ID,请使用数组中的choiceproducts。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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