Contentful logo

Contentful Community

Boolean field return null when false value is selected

Hi,

I dont know why, but on a boolean field when i select the false value i get null instead of false.

Is that normal?

Thanks

Hi @olivier.castro-perri,

Could you explain how exactly you’re getting this value? Is it through the API?

Also, would it be possible to provide some actual examples/screenshots of this? (without any sensitive information, of course)

I make a simple query on a content-type that contains a boolean field.

when accessing the field i get null even if i checked it as false.

    $query = $this->getQuery();
    $results = $this->getEntries($query);

    foreach ($results as $menuItem) {
        dump($menuItem->get('has_slider'));
    }

$menuItem->get(‘has_slider’) here return null, but is checked as false.

Okay, for a strange reason, the boolean field was not filled so it was returning null even if i had checked it.

If the field doesn’t actually have a value, it shouldn’t retrieve false, and in fact it wouldn’t be retrieved.
Would it be possible for you to request directly through our API (with cURL/Postman) and compare that with the response from the SDK?