There is FieldtypeFleat field "my_float_field". I have few (strange) issues with it - I think they are connected, so posting both here.
Issue with storing/getting
When I want to store null in this field, it doesn't save (or return) null. I want to get null back when I save null and 0 when I save integer 0. What's wrong here?
$value = null;
echo 'Type=' . gettype($value) . ' Value=' . print_r($value, true));
$page->setAndSave('my_float_field', $value);
echo 'Type=' . gettype($page->my_float_field) . ' Value=' . print_r($page->my_float_field, true));
echo 'Type=' . gettype($page->my_float_field) . ' Value=' . print_r($page->getUnformatted('my_float_field'), true));
// Result:
Type=NULL Value =
Type=double Value = 0
Type=double Value = 0
Issue with visibility
This field has Visibility=Open+Closed when blank+Locked
If I save null in this field, it disappears from page edit admin. If there is some value - it shows it normally... If I change setting "Blank and 0 have different meanings" to "... equivalent" it also does not help. This looks like either bug or some db issue. I've checked field settings in db and didn't find any strange things there... so tend to think that it is bug.
Request to support is here https://processwire.com/talk/topic/14355-few-strange-issues-with-storinggetting-null-in-float-field/#comment-129154 but answers do not fix issues.
- ProcessWire version: 2.7.2
- (Optional) PHP version: 7.0.11
- (Optional) MySQL version: 5.7 (ALL TABLES ARE INNODB)
There is FieldtypeFleat field "my_float_field". I have few (strange) issues with it - I think they are connected, so posting both here.
Issue with storing/getting
When I want to store null in this field, it doesn't save (or return) null. I want to get null back when I save null and 0 when I save integer 0. What's wrong here?
Issue with visibility
This field has Visibility=Open+Closed when blank+Locked
If I save null in this field, it disappears from page edit admin. If there is some value - it shows it normally... If I change setting "Blank and 0 have different meanings" to "... equivalent" it also does not help. This looks like either bug or some db issue. I've checked field settings in db and didn't find any strange things there... so tend to think that it is bug.
Request to support is here https://processwire.com/talk/topic/14355-few-strange-issues-with-storinggetting-null-in-float-field/#comment-129154 but answers do not fix issues.