0

I defined the hook_views_data in order to display some data from a custom table in the database. One field is a nullable decimal(5,1). The value of this field is displayed correctly in the view but shows nulls as 0.0. "No results behavior" seems to have no effect on it in any way. The field is defined as follows:

$data['customview']['value'] = array(
        'title' => t('value'),
        'help' => t('the requested value'),
        'field' => array(
            'handler' => 'views_handler_field_numeric',
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        'filter' => array(
            'handler' => 'views_handler_filter_numeric',
        ),
    );

Using PHPMyAdmin, I can verify that the values are null. Any custom properties I should add to the definition of the field in order to allow nulls (Display them as empty or dash)?

1
  • 2
    There are quite a few issues with views and checking to see if fields are empty/null then what to do with them after, here is an issue you may want to take a look at as it sounds very similar to your issue here: drupal.org/node/1232920 there is some patches on that, even if you didn't want to patch you could make a custom views handler using their methods there to fix the issue if needed b/c I don't think anything on this issue and another has been committed to views dev to fix them. Jun 28, 2015 at 3:48

1 Answer 1

1

There are some issues in the views queue that can help out with fixing these issues. This issue is very similar to the issue you are having (Empty rounded numeric fields not hidden properly). It has a patch that should fix the issue that has been reviewed and tested by the community but has not made it into dev yet. You could either patch views or write your own numeric views handler to fix this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.