The node.module builds the Author Information, Publishing Options and Submit buttons outside of the normal form building process. This prevents using hook_form_alter() and weights to affect the placement of these items on the page. Further it prevents anyone from adding things such as markup text after the submit buttons should they choose to do so.
theme_node_function() (node.pages.inc @2202) has the following comment.
// Admin form fields and submit buttons must be rendered first, because
// they need to go to the bottom of the form, and so should not be part of
// the catch-all call to drupal_render().
In user testing there does not seem to be a detrimental effect. This patch also re-weights these items to maintain the traditional page flow using weights of 90, 95 and 100 respectively.
Comment | File | Size | Author |
---|---|---|---|
#1 | 296918-1-node.form_.patch | 2.26 KB | jbrauer |
Comments
Comment #1
jbrauer CreditAttribution: jbrauer commentedComment #2
catchI have two HEADS held up waiting for fresh dtbng benchmarks, but visually this looks great (yay, less code), and I can't imagine why this was ever there in the first place.
Having said that, do we need the rest of the stuff in theme_node_form() any more, what about just killing it altogether?
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedbookmark
Comment #4
Dries CreditAttribution: Dries commentedApplying this patch doesn't seem to alter the form (visually) at all. Is that correct? If so, looks like a good clean-up.
Comment #5
kscheirerpatch works and applies cleanly.
Visually there are no changes. The HTML structure is altered somewhat though. Doesn't seem like a big change to me, but could this change require some themes to be updated?
Pre-patch most of the node form is in a
<div class="standard">
, the "Authoring Information" and "Publishing Options" fieldsets are in a<div class="admin">
and the buttons are not in either.Post-patch the node form, all fieldsets, and the buttons are in
<div class="standard">
Comment #6
jbrauer CreditAttribution: jbrauer commented@Dries that is correct
@kscheirer is correct in that it does eliminate the class "admin" on the publishing options section. This could be added if it is seen as critical but I couldn't find where it's used in system, default or node css files. In the use cases I've had I've had need to override this anyway if it is being used for theming.
Comment #7
catchI looked again, and I really can't see any reason for theme_node_form() now. No particular need to wrap it in a div given the entire form has an id.
Comment #8
floretan CreditAttribution: floretan commentedTested this too, and I can confirm the above comments.
The code looks good, so I'm marking this as RTBC.
The HTML changes probably won't affect contrib themes, but they might affect custom themes with specific overrides, so we should mention the change in the "theme 6.x to 7.x upgrade guide" once this gets committed.
Comment #9
jbrauer CreditAttribution: jbrauer commentedI did an alternative that removes the theme_node_form() function.
There is a minor consequence with this (and indeed if we go this route we should take the corresponding .node-form classes out of node.css or find a different approach to utilizing them.
The visual effect of this is to have the fields default to 50% wide (approx) and while the other elements don't affect display in Garland they would have more impact on other themes that potentially count on them being there. So with that it seems that perhaps keeping the minimal function is the better path?
Comment #10
catchWe could make all those .node-form into #node-form maybe? However I don't think that should hold up this patch, so tested it as well, and leaving at rtbc.
Comment #11
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #13
sunTo be continued in #596582: Remove remnants of theme_node_form() - now.