简体   繁体   English

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

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

I am working with a CMS like system, phpBMS, which defines a certain way of making forms, and defines the form elements to be used in such forms. 我正在使用类似CMS的系统phpBMS,该系统定义了某种制作表格的方式,并定义了在此类表格中使用的表格元素。

This is an example of the form template, and these are the fields that are defined. 是表单模板的示例,并且这些是定义的字段。

Generally, it is pretty simple. 通常,这很简单。 If you have an inputField with the id of say, 'name', the content of that field will be saved to the name field in the table the form is assigned to. 如果您有一个id为“ name”的inputField,则该字段的内容将保存到分配表单的表的name字段中。

Currently, I am using a different input field, inputSmartSearch, which works a bit like google suggest as it can search and automatically display results as you type. 目前,我使用的是另一个输入字段inputSmartSearch,它的工作原理类似于google建议,因为它可以在您键入时搜索并自动显示结果。

I want to use the content of this field to go into a 'product' table, but I am unsure of how to set this up. 我想使用该字段的内容进入“产品”表,但不确定如何设置。

I am calling my smartsearch like so: 我这样称呼我的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);

When I look what is returned by _POST, I see: 当我查看_POST返回的内容时,我看到:

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

I have setup the quantity and type fields like so 我已经像这样设置了数量和类型字段

    $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);

The content of the type and quanitity fields get insert into the database perfectly, but absolutely nothing gets inserted from the smartsearch field. type和quanitity字段的内容可以完美地插入数据库中,但是从smartsearch字段中绝对不会插入任何内容。

Why? 为什么? How would I start to troubleshoot this? 我将如何开始对此进行故障排除?

I think in this case you would need to manually add this value to the array that is persisted to the database. 我认为在这种情况下,您将需要手动将此值添加到持久化到数据库的数组中。 So: 所以:

$variables["product"] = the value you want $ variables [“ product”] =您想要的值

So if you san. 所以,如果你圣。 To persist the name assign Ds-chooseproducts. 要保留名称,请分配Ds-chooseproducts。 If you want to persist the id then use chooseproducts from the array. 如果要保留ID,请使用数组中的choiceproducts。

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

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