Problem/Motivation
Views' "Add field" forms have default configurations that are not optimized for working with fielded views + Fences. There are several checkboxes that need to be toggled for every field that is added to a view. It would be very nice if Fences changes the default configuration when you add a field to a view.
Greg tried using a simple form_alter, but changing the #default_value actually means that the field will always have that default value even if you specifically change that toggle in the UI while editing the field. In other words #default_value is acting like #value for these forms.
fences_form_views_ui_config_item_form_alter()
fences_form_views_ui_edit_display_form_alter()
Here's the list of things we want to change the defaults for:
- Turn off "Create a label". We almost never want the field's label.
- Style settings:
- Turn on "Customize field HTML". We don't want the default Views wrappers.
- Set "HTML element" to "- None -".
- Turn on "Customize label HTML".
- Set "Label HTML element" to "- None -".
- Turn on "Customize field and label wrapper HTML".
- Set "Wrapper HTML element" to "- None -".
- Turn off "Add default classes". We don't want Views' field classes because the field's classes are enough.
- Turn on "Use field template". Otherwise Fences' configuration isn't used.
Proposed resolution
Muck around with HOOK_form_views_ui_add_item_form_alter() to see if the configuration defaults can be inserted into the View object before the views_ui_config_item_form form and the views_ui_edit_display_form form are displayed.
User interface changes
Makes Views' default configuration options be Fences-friendly, but let administrators change the default configuration options.
Original report by stevector
This was brought up on the last day of the sprint. Right now Fences automatically checks the "Use field template" box every time a field config form is opened. This is done in a form_alter and it does not remember if that box was previously unchecked. I think this can be fixed by using a submit handler on the add form. I spent some time trying to get that to work and failed. I'm recording it here as an issue to keep track of this need.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1300576-6-views-defaults.patch | 3.57 KB | johnalbin |
| #5 | 1300576-5-views-defaults.patch | 3.18 KB | johnalbin |
Comments
Comment #1
johnalbinWait… so you mean when you add a field in Views, that Views actually adds the field and then displays the options form for that field?
Do you know the hook for altering a field on a View when it's added?
Comment #2
stevectorThis is what I was trying to work with. I think the submit function needs to alter the View object so that the fields have that flag set before the next form, views_ui_config_item_form, is generated. I don't recall exactly where I was going wrong. Maybe we should talk with Earl about this.
Comment #3
agentrickardTrying to understand exactly what the intent is with Views.
What are the requirements?
Comment #4
johnalbinI edited the issue description above, Ken.
Because the form alters were causing critical UI issues, I've commented them out for now. So bumping this back to "major".
Steve, yeah, after I posted my comment above I found the HOOK_form_views_ui_add_item_form_alter() and was dsm'ing it to hell. Still haven't found the magic bullet.
Comment #4.0
johnalbinAdd issue summary
Comment #5
johnalbinHere's a patch that gets closer to where the problem occurs. But it still doesn't actually work. :-p
Comment #6
johnalbinFixed it!
Well… I fixed the fences_form_views_ui_config_item_form_alter() part. I added a temporary property to the View when the fields are added. And then use that property to tell if the field is "new" when its options form is displayed. Here's the patch I committed.
There still remains the
fences_form_views_ui_edit_display_form_alter()form alter. :-\Comment #7
johnalbinWe were trying to uncheck the "Provide default field wrapper elements" box on the Field row settings form. That setting is going to require a different strategy then we used above. If we are building a fielded view, we may not actually go into the Fields Row Options form. We need to alter the View to have a different default for its row_options.
I can't tell which properties of the View I need to alter. I see these, but I think there are similarly-named properties elsewhere in the View:
Actually, thinking about this some more… we are already removing Views' wrappers and just using Fences' wrappers around all field-api fields. Any other kind of field is just a "Views field" and, surely, that does need a default wrapper around it? Ok, I'm going to remove that form alter stub and close this issue.
Comment #8.0
(not verified) commentedUpdate issue summary.