开发者

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.

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->set开发者_Python百科Attribute("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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜