dropdown list - value "" in database

nadjak

Member
Hi,

I have a dropdown list in my form. The first item is "please select" and the value ist "" (empty). The list is not required so there can be entries in the database with "please select". But I don't want to have the "please select" in my database. There should be saved nothing (the value of the item is "nothing". It is empty).
I already tested a blanc in the item value. But in the database is saved "please select".
how can I save a blanc or nothing in the database if the dropdown list is not selectes?
Thank you
nadja
 
I can't replicate that.

Here's one of my test forms, with a dropdown with a blank value for 'please select', and as you can see, the underlying database field changes to blank when it is submitted with "please select".

Sorry about the long pause after submitting the form in the screencast, I forgot I had a breakpoint in some other code (the article plugin) which I was working on yesterday, so my debugger cut in, and I didn't notice. Anyway ... the important art is the Navicat (database tool) view of that row before and after submitting.

http://screencast.com/t/CUvWD1xZD

-- hugh
 
Are you sure it's actually saving 'please select', or is that just what you are seeing in Fabrik's list display?

-- hugh
 
You are right.
In the database it is the blanc. But if I export the data to csv or in the detail display there is shown "please select" and not the blanc.
Has anybody an idea how to solve this?
Thank you
Nadja
 
That's just how exporting works. The raw value of "" corresponds to the label of "Please select".

We allow exporting of raw data, which would just be the blank field.

I'm working on extending the listcsv plugin to allow modifying data as it is exported, so there may be a solution soon.

-- hugh
 
As of this commit:

https://github.com/Fabrik/fabrik/commit/ee9335ee9b74b427da1b06a4694946326ef9e3a3

... there is now settings in the listcsv plugin to modify exported data. Doing ...

Code:
if ($listModel->csvExportRow['yourtable___yourdropdown'] == 'please select') {
   $listModel->csvExportRow['yourtable___yourdropdown'] = '';
}

Replace the element name with your full element name, and 'please select' with the exact string (case sensitive).

In the new "CSV export code" would achieve what you need.

See the wiki for how to update from github, and "discover" plugins.

-- hugh
 
No.
I assume your problem is that you are using a dropdown element.
This doesn't have a "Please select" mechanism, you only have added one option (like all other options) with the text "Please select"
Put your options in an extra list and use a dbjoin element.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top