Hello
Some times we are using if else to get end value.
if- Good --- $entity_field[0]['value'] = number_format($t,2);
else - NG ---$entity_field[0]['value'] = "";
The problem is $entity_field[0]['value'] = "";
still show the label. I had test ver 1.0 &1.1 0&dev
also get the label show, even the value empty.
How to fix that? or what I'm missing?
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff-2663140-6-7.diff | 3.04 KB | colan |
| #7 | computed_field-check_for_empty_values-2663140-7.patch | 4.27 KB | colan |
| #2 | Capture.PNG | 10.88 KB | chansionjoe |
Comments
Comment #2
chansionjoe commentedIV Item #1 have value
QTY - Decimal filed - display(value&label) ; price - computed field - display(value&label)
IV Item #2 no value
QTY - Decimal filed - none display(value&label) ; price - computed field - I want to none display (value&label)
Comment #3
ram4nd commentedComment #4
hugronaphor commentedJust define $entity_field = NULL; before trying to populate with values.
Comment #5
colanAs I just discovered, this is still a problem in D8, even if NULL is returned. Let's fix it there first.
I think the D7 problem was fixed in #1928178: Hide field when output is empty (and DB is not used for storage). We should probably try porting code from there.
Comment #6
colanisEmpty()was simply returning FALSE. With this patch, the computations are actually run to determine if the values are empty or not.The D7 code wasn't helpful at all because it's procedural, not object-oriented.
I'm not crazy about having this code block in 3 places (for strings, integers and decimals), but it seemed less confusing than introducing yet another trait for classes that override
executeCode():Comment #7
colanI wasn't comfortable with the duplicated code so I finally added the new trait.
Comment #9
tonypaulbarkerThis is still a problem. isEmpty is just set to FALSE regardless of calculations.
I need to set null values so I can average later with aggregation in views and not have incomplete fields scoring zero and bringing down the average.
#7 works well for me.
Comment #11
colanThanks for the review!