Gossamer Forum
Home : Products : DBMan : Discussions :

drop-down list values lost when edited?

Quote Reply
drop-down list values lost when edited?
One of my fields is the Location (state) and I have dbman building this by entering the state list in default.cfg. The problem is that if someone enters their state, then edits their record, then saves the edit, the state they entered when their first created the record is lost (presumably because when they edit the drop down list is created from scratch)

Is there an easy way to make the selected option in the drop down list the value they entered when creating the record so the state does not get reset (to nothing) when someone edits their record?

Thanks.

From my default.cfg
(snip)
state => [5, 'alpha', 0, 15, 0, 'Florida', ''],
(end snip)

(snip)
# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
'state' => 'Alabama ,Alaska ,Arizona ,Arkansas ,California
,Colorado ,Connecticut ,Delaware ,Florida ,Georgia ,Hawaii
,Idaho ,illinois ,Indiana ,Iowa ,Kansas ,Kentucky ,Louisian
,Maine ,Maryland ,Massachusetts,Michigan,Minnesota
,Mississippi ,Missouri ,Montana ,Nebraska ,Nevada
,New Hampshire,New Jearsey ,New Mexico ,New York
,North Carolina,North Dakota ,Ohio ,Oklahoma ,Oregon ,Pennsylvania
,Rhode Island ,South Carolina ,Tennessee ,Texas ,Utah ,Vermount ,Virginia
,Washington ,Washington D.C.,West Virginia ,Wisconsin ,Wyoming'
);
(end snip)

Quote Reply
Re: drop-down list values lost when edited? In reply to
OK - looks like it was the spaces between items. I was thinking that I had used the online configuration tool to setup the fields, so I didn't think that would be the problem, but I probably messed that up by myself.

One question - in another thread I see mention of build_select_field_from_db

When should I use this instead of just
build_select_field

Quote Reply
Re: drop-down list values lost when edited? In reply to
You should use this for user-defined fields, not fields that you configure in the default.cfg.

Example, if you want to build a select menu for NAMES in your database, you would use that sub.

Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: drop-down list values lost when edited? In reply to
build_select_field_from_db can also be used with a custom search form.

This way rather than displaying all the selections, only the selections currently in the database will be displayed.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/