Hi, to properly use search and filters on a numeric field, the DB column must be declared as INT (or its variations, SMALLINT, etc. etc.) while the Seblod field is a text one. Easy example a field "price".
Now the question is: when that field has no value (e.g. the price is still unknown), so the text field value is an empty string, Seblod does not store NULL (of course the DB column has the NULL attribute), but... the value 0, that is wrong (it's not free :)).
How to tell Seblod to store NULL when a value is empty? Of course the word "NULL" in the default box of the field definition is not a good idea...
Note that if the DB column would be VARCHAR, then Seblod stores an empty string that is fine, but a VARCHAR field is not usable for a numeric field...
Very strangely this works only on creation and not on edit: when I create a new content item and leave the numeric field empty, the beforeStore does its job and a NULL value is stored into the DB instead of a zero.
BUT... if I edit that item, fill the the field with any value like 1, save the item, then edit again the item clearing the value in the form: the beforeStore field replaces the empty string with a NULL value but Seblod does not store that NULL and leaves the 1 in the DB...
I checked with error_log tracing that beforeStore is correctly executed.
How to tell Seblod to store a NULL value for a numeric field?
Probably some logic that expects that form value can't be null after it has a value. Workaround would be to use empty string like "" and then in afterStore run some query that sets all empty strings in column to NULL like
UPDATE your_table SET your_column = NULL WHERE your_column = '';
Ok, I will do with an afterStore field, I edited the Github issue asking that Seblod stores "NULL" and not "0" into a numeric field where the value is empty., I hope it will be taken into consideration since optional numeric fields are widely used.