⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

Dropdown field type problem

dropdown input field

  • Please log in to reply
2 replies to this topic

#1 RMaynard



  • Members
  • Pip
  • 7 posts

Posted 08 November 2017 - 07:02 PM

This is my first time using this platform and have a problem with the dropdown input type. If I use the following code:

array('1' => 'corps', '2' => 'fs','3' => 'katy','4' => 'mocons','5' => 'mopark','6' => 'nps','7' => 'ot'));
It works pretty much as expected when entering a new record, however, when editing a record the 'agency' field doesn't show the value already in the record, just the dropdown. Since this is not a requird field, if you don't know what is in the field and don't choose one, updating the record stores a null in the field and the information is lost.
Is there a way to default the input field to the value in the record and show the contents of the 'agency' field when the edit page loads?  Does this require a callback function like callback_edit_field(), and if so how do I implement it?
Thanks for your help.

#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 09 November 2017 - 04:17 AM

Well my friend,


very 1st thing - can you update me on 1 thing - is there  a field (agency) stored in the table? if so, can you cross check if the relevant value is going into the table during insert?


1 thing - if you always have this static values - then i will rather recommend u change the field to enum. If you anyways going to store just IDs - then u better have another table to which u join in with relation.

#3 RMaynard



  • Members
  • Pip
  • 7 posts

Posted 09 November 2017 - 12:21 PM

Amit, thanks for your help. I do have a field 'agency' and I will only have a small number of possible values stored there, so thought it overkill to have a table with just 4 or 5 values. I think I may have this working. The field 'agency' is a type varchar(20) and I think my original code was storing a numeric value there. I chanced it to the following and it seems to be working now.

array('corps' => 'Corps of Eng', 'fs' => 'Forrest Service','katy' => 'Katy Trail','mocons' => 'MO Conservation','mopark' => 'MO Parks','nps' => 'National Parks','ot' => 'Ozark Trail'));


I know just enough to be dangerous :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users