Problem/Motivation
Currently you can configure the output of a boolean field on a field settings level. For views itself though there are more use cases:
- You want to output 0/1 for raw data output
- For some nice listings, you might want to support some unicode chars
-
These are the default options + a fully customizable one.
$default_formats = array(
'yes-no' => array(t('Yes'), $this->t('No')),
'true-false' => array(t('True'), $this->t('False')),
'on-off' => array(t('On'), $this->t('Off')),
'enabled-disabled' => array(t('Enabled'), $this->t('Disabled')),
'boolean' => array(1, 0),
'unicode-yes-no' => array('✔', '✖'),
);
While we are converting base fields to use field formatters, this lack of support for boolean formatting causes problems in #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency. Once #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency gets in, not having all those options available on the boolean formatter would be a regression.
Proposed resolution
Extend the boolean field formatter with options to support these display formats. This will allow #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency to not regress functionality for boolean fields.
Remaining tasks
Commit.
User interface changes
Boolean fields have more flexible display formats.
API changes
The boolean formatter schema is slightly expanded.
Beta phase evaluation
Issue category | Task, because its a part of not getting a regression, see #2342045-62: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency |
---|---|
Issue priority | Normal, because this issue just affects the rendering of booleans, but they ARE really common in admin UIs |
Disruption | Not disruptive, the existing boolean outputs will continue to work. |
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff.txt | 2.88 KB | dawehner |
#11 | 2395613-11.patch | 8.63 KB | dawehner |
Issue fork drupal-2395613
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
dawehnerComment #2
dawehnerComment #3
jhodgdonWould it be a problem to add these options to the standard boolean field formatter, or to define additional Formatter classes for Boolean fields with these options available?
Comment #4
dawehnerWell ... the problem is more about knowing what kind of features we still want to support, and which are just too special.
So far this ports over the listed formatters, BUT in views you can even configure your own one.
Comment #5
jhodgdonOK... I looked at what Views gives me now (without any patches) to configure the "Published" field in a node view, and as you say there is also the option "custom", which is basically to provide a value to display for true and a value to display for false. Is there a reason we can't add this option too? It doesn't seem all that complicated, and would require just two more settings strings for the labels.
Comment #6
dawehnerSure, let's do that.
While writing a test I realized that unicode (as supported by views) somehow doesn't work here.
There is no investigation yet, but just to say it, this patch will fail.
Comment #8
dawehnerUps, I simply mixed up true and false :)
Comment #9
dawehnerComment #10
Wim Leers:D
s/Fallback/Fall back/
The array structure is not followed by this last one. I understand why; but wouldn't it be better to list an empty array in this case, and explicitly document it; referring to the associated settings?
I think we usually have a blank line between these?
Comment doesn't match what happens.
.
Probably also needs the beta evaluation in the IS.
Comment #11
dawehnerWell yeah, I tried to make the code as simple as possible, maybe you like the slighly longer version better?
Alright, dropped it.
Added the beta evalution.
Comment #12
Wim LeersAh, yes, now I understand; I didn't realize you were exploiting the behavior of
implode(' /', $array)
with$array
a single-valued array.I wonder if this is really better.
Since this is protected anyway; why not only list "actual" formats here, and just append the 'custom' one in
::settingsForm()
. Then all data returned by::getOutputFormats()
would be of the same form!Other than that, this looks ready to me :)
Comment #13
dawehnerI kinda like to have a good place in the code to see all options though.
Comment #14
Wim LeersOk; that detail is not important enough to debate further. Let's do it.
Comment #15
dawehnerThank you!
Comment #16
alexpottThe beta evaluation lacks details about exactly what regression this is fixing.
Comment #17
dawehnerComment #18
Wim LeersComment #19
jhodgdonUm. The issue summary is making two references that should be to other issues but are pointing back to this issue... not sure which issue should be pointed to or I'd fix it (I keep getting confused about which issue is doing what lately on the Views stuff).
Comment #20
Gábor HojtsyUpdated issue summary with correct links, more details. This issue is currently rolled into the core critical #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency, so marking it a blocker as well.
Comment #22
alexpottThis is part of making views use field formatters and not regress. Thanks for adding the beta evaluation to the issue summary.
Committed d2ff08e and pushed to 8.0.x. Thanks!
Comment #25
jhodgdonFollow-up if anyone wants to take a look at this:
#2428087: Boolean field formatter - default choice appears in list twice