Gossamer Forum
Home : Products : DBMan : Installation :

Select-field returned without any value

Quote Reply
Select-field returned without any value
I have a problem with select fields.
My database works otherwise just fine, but when I try to modify my records, the select-field does not have any value in it.
I have use &build_select_field function and the value is returned right when searching. Only when modifying value is the default '---'.
Quote Reply
Re: Select-field returned without any value In reply to
The only time I've seen that happen is when there's a typo somewhere in the field name. Look at your &build_select_field command. It should be

&build_select_field("fieldname","$rec{'fieldname'}")

My guess is that the part that I bolded has a typo.


------------------
JPD





Quote Reply
Re: Select-field returned without any value In reply to
Everything seems OK to me.
&build_select_field command is also OK, it is just like it was when I downloaded it.
I noticed that if the value of that select field is the first one in the field name list, it is returned right in the modify page but any other value, it is '---'.
I can get this kind of working using &build_select_field_from_db but I really need to use &build_select_field.
Quote Reply
Re: Select-field returned without any value In reply to
If you're sure there's no typo, I don't have any clue what could be wrong. I do know that I was having the same kind of problem and I looked at the script probably 20 times before I realized that I had misspelled the field name.

The only reason it wouldn't work is if it is unable to recognize the value of the field in the record. If there's not a problem with the $rec{'fieldname'} variable, then, for some reason the wrong value is being written to the record.


------------------
JPD





Quote Reply
Re: Select-field returned without any value In reply to
These are what I have in my scripts:

default.cfg:
Toimiala => [2, 'alpha', 0, 255, 0, '', '']
...
%db_select_fields = (Toimiala => 'Something,
Something else,
Still more');


html.pl:
<TD VALIGN=TOP> |; print &build_select_field ("Toimiala", "$rec{'Toimiala'}"); print qq|</TD></TR>

Quote Reply
Re: Select-field returned without any value In reply to
Looks like it's okay to me, too. (It's not that I didn't trust you. It's just that all I have to go on is my own experience. Smile )

Just for debugging purposes, try putting in one of the values that is in your select list--

&build_select_field{"Toimiala","Something")

See if "Something" is selected when you go to the modify form.



------------------
JPD





Quote Reply
Re: Select-field returned without any value In reply to
I tried that and no, it is still '---'.
Quote Reply
Re: Select-field returned without any value In reply to
Okay. Now we're getting somewhere.

You don't have any leading or trailing spaces in your select field definition, do you?

Wait a minute. I remember why I had a problem with this. (Another problem. :-) ) Try putting your select field options all on one line--

Code:
%db_select_fields = (
Toimiala => 'Something,Something else,Still more'
);

It makes it harder to read, especially if you have a whole lot of them, but I think this will make it work.


------------------
JPD





Quote Reply
Re: Select-field returned without any value In reply to
Now it works! Thank you. I would never have guessed that was the reason.
Quote Reply
Re: Select-field returned without any value In reply to
No problem. Smile It took me a long time to figure out, too, and then I promptly forgot it or I would have told you about it sooner! Smile


------------------
JPD