Abu,
below posts the V value, not the K (so [ProjectNumber]+’ – ‘+[ProjectName] ). Ofcourse can do after_insert stuff, but why does this work differently than a select alternative, which is user unfriendly?
$colb[“formatter”] = “autocomplete”; // autocomplete
$colb[“formatoptions”] = array( “sql”=>”SELECT DISTINCT ProjectNumber AS k, [ProjectNumber]+’ – ‘+[ProjectName] AS v
FROM Y_MD_ProjectForeCastSystem order by ProjectNumber”, “search_on”=>”concat(ProjectNumber,’ – ‘,ProjectName)”);
Option 1: In autocomplete, you can specify another field (client_id) that will be filled with K (key) values after selection and it can be posted as well.
$col[“formatoptions”] = array(“sql”=>”SELECT client_id as k, name as v FROM clients”, “update_field”=>”client_id“);
Option 2: Use select2 dropdown. It has default functionality to show label and post key on backend. Refer demos/integration/dropdown-select2.php
yeah well, option 2 is not really userfriendly, and suppose you have table where projectmumber is key and the projectname you have in a seperate masterdat table. Ofcourse you want to show the name, but soonest you put than on editable, record gets stuck on insert as well (as it’s not part of the updated table) . Everybody that saves names in linked tables (which in a way seems normal practice) has the same problem. The as k as v you present in the demo, is kind of suggesting that the logic would work as with option 2. But ok i take it as given for now,
The limitation we have here is auto complete is applied on input box which can have one value, either key or value. Where as drop-down can have two value and key/value post/display is doable there. Hope you understand.