doujia1939 2010-07-02 10:34
浏览 34
已采纳

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

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.

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.

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.

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:

    $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:

Array ( [chooseproducts] => 75c72a6a-83d9-11df-951a-fa9c1ec271f2 [ds-chooseproducts] => Corona [quantity] => 2 [type] => cash)

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.

Why? How would I start to troubleshoot this?

  • 写回答

1条回答 默认 最新

  • ds08541 2010-07-03 21:04
    关注

    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

    So if you san. To persist the name assign Ds-chooseproducts. If you want to persist the id then use chooseproducts from the array.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备