Page 1 of 1
LISE saving value 0 (zero) not saved
Posted: Fri Mar 04, 2016 1:01 pm
by eus
Hello,
Is it possible to store the value 0 (it's the text_input field).?
I think it's something in the core. I want to use it for a module where i can store a team result.
"0 will work, so i can strip it in the frontend but maybe there are other solutions or tricks.
Thnx
Re: LISE saving value 0 (zero) not saved
Posted: Fri Mar 04, 2016 3:12 pm
by Jeff
If it doesn't store then output 0 as default.
Code: Select all
{if !empty($field->value)}{$field->value}{else}0{/if}
*this is pseudo-code, I haven't look at the template to know how LISE make var available.
Re: LISE saving value 0 (zero) not saved
Posted: Fri Mar 04, 2016 3:17 pm
by Rolf
In short {$field->value|default:'0'}
Re: LISE saving value 0 (zero) not saved
Posted: Fri Mar 04, 2016 3:27 pm
by eus
Thanks for the tips and shortcode.
It will work in many solutions but the field i've got is a "score" field. So it can be 0,1,2,3,4 etc.
The frontend then shows 0 as a score. The admin also doesn't show 0 but blank. I think indeed that 0 will not store in the database.
This is a workaround. Ik can tell the user to fill in "00" instead of "0"
if $field_value == "00" -> "0" in the frontend.
Re: LISE saving value 0 (zero) not saved
Posted: Fri Mar 04, 2016 3:49 pm
by Jeff
Check to see if you can put a "default value" when you setup the field?
It isn't an issue with storing in the db, it is possible it is in the security checks when submitting the edit form (it probably checks !empty() ).
Alternatively, you can use custom templates in that Admin to add the "|default:0" as well.
Re: LISE saving value 0 (zero) not saved
Posted: Fri Mar 04, 2016 9:34 pm
by velden
In my opinion you should try to file a bug report.
'0' should be a valid string. I think we all agree on that.
Filing a bug report informs the developer and he might think of a solution and fix it for next releases.