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.

CommentFileSizeAuthor
#1 296918-1-node.form_.patch2.26 KBjbrauer
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jbrauer’s picture

Status: Active » Needs review
FileSize
2.26 KB
catch’s picture

I 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?

Anonymous’s picture

bookmark

Dries’s picture

Applying this patch doesn't seem to alter the form (visually) at all. Is that correct? If so, looks like a good clean-up.

kscheirer’s picture

patch 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">

jbrauer’s picture

@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.

catch’s picture

I 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.

floretan’s picture

Status: Needs review » Reviewed & tested by the community

Tested 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.

jbrauer’s picture

I 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.

.node-form .form-text {
  display: block;
  width: 95%;
}
.node-form .container-inline .form-text {
  display: inline;
  width: auto;
}
.node-form .standard {
  clear: both;
}
.node-form textarea {
  display: block;
  width: 95%;
}
.node-form .attachments fieldset {
  float: none;
  display: block;
}

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?

catch’s picture

We 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.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

sun’s picture