Default Content
Default Content
karlie
Posts: 83Questions: 17Answers: 0
Apologies if this is covered somewhere, but I haven't found a solution. If I edit a record and one of the fields is blank, when the record saves it inserts 0.00 into the blank table cell. I have tried adding:
{
"label": "Each:",
"name": "each_price",
"defaultContent": ""
},
An suggestions?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The issue might be on the back end.
Can the database accept empty string? And is the database default 0?
Also, what are you hoping to insert into the field?
null
?If so, then maybe
null
(orfunction () { return null; } )
) for the default content might work.Just tried default content as null
Sadly that didn't work.
With the quotes around it it's interpreted as a string that incidentally says "null" rather than an actual
null
value.Try null without the quotes:
If that doesn't work then try the function that returns null without any quotes:
https://editor.datatables.net/manual/php/formatters#Examples
Apply a formatter to your editor field. I use "null if empty"
@tangerine's solution is a good one too! I had forgotten about that!
Thanks both of you for your help. @Loren Maxwell those aren't working sadly.
@tangerine could you assist me with where exactly it goes in the editor code?
I thought of just targeting it with CSS but guess 0.00 would still be exported in CSV and Excel from the buttons
The formatter @tangerine is referring to would go in your PHP file "php/my_ajax_file.php".
Haha, can't believe I was being so thick, that works, thanks very much both!
Just need to update all the records now to get rid of 0.00 in rows that have already been edited. Might just import through phpmyadmin
I'm not sure whether you're asking, but anyway....
Thanks Tangerine, I took the longer route, I exported it, did a search and replace, and imported again!