0

in a Drupal 8 installation I have a form ( webform ) in which numbers are entered ( they are tests of the water, like pH, KH etc.), these numbers are then made visible to the user through a view and the numbers entered are associated with the date.

So at the end a standard list comes out:

07/07/2020 | KH = 3
06/07/2020 | KH = 2
etc.

The problem I find is that when in the view I set a filter, like not null or (!= ) the fields in which zero is entered are treated in the same way as those that have been left empty, so the view displays everything and I come up with something like

07/07/2020 | KH = 3
06/07/2020 | KH = 2
05/07/2020 | KH = 0
04/07/2020 | KH =

In the previous example the last test of 04/07/2020 was not filled in but in the view the date and the empty Kh field appear anyway.

I tried to set as filter Kh NOT NULL or Kh (!= ), but the view treats me the zero in the same way as the empty field so the empty fields continue to appear in the list, while I would like to exclude them. Do you have any idea? Thank you.

P.S. another strange thing is that if I use a normal numeric field in a content type everything works, if I set a view and put as a filter for example Kh (!= ) all zeros are included in the list and fields left empty are excluded;If instead I use a numeric field from webform the zero and the empty fields are treated in the same way so if I exclude the empty fields also disappear those in which zero has been entered as a value.

  • 1
    Is your field type Number? Check the Field settings under No results behavior. There are options that may affect your results Count the number 0 as empty and Hide if empty. – prkos Jul 29 at 0:47
  • Yes, it is a number, and I tried to play with the options that you mentioned, but for example if I deselect "Count the number 0 as empty" an I select "Hide if empty" I lose both the zero values and the empty values, while in theory the opposite should happen, zeros should be added to the list and empty fields should disappear. May be is a problem related to webform ? – Alessio Pellegrini Jul 30 at 9:39
  • To me it seems like it's in how Views treat number fields, it does seem strange. – prkos Jul 30 at 16:37
  • 1
    Yes it is strange, I tried using a number field in a content type and it works perfectly, I made a view and I used the filter (!= ), in this way entered zeros are displayed while values left blank are excluded; If I use webform as a data source everything stops working, the problem is that I really need to use webform. – Alessio Pellegrini Jul 30 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.