All,

I have found that deep inside the node module there are "divs" put in there which 1st denote that the form is a "node-form" and then separately denote whether or not it is "admin" or "standard".

My thought is that this is really in the wrong place. First I'm not entirely sure I understand why these are in here. If anyone knows why this bit of form information should be treated different than other form information, please let me know.

Second...it seems odd to me that only "node-forms" are called out as different (and hence can be themed using CSS). I'm cool with the concept of differentitating different types of forms...and even different pieces of a form...but there may be a cleaner (more themeable) way to accomplish this.

I'd propose that we add a parameter to the form function in the common.inc that would allow for a "type" to be specified. Then we can assign the type to the form itself (allowing CSS to handle different classes of forms separately.

Second, If it is important to have sub-groupings within forms we should create a construct for such a thing. I would suggest adding another form function ("form_chunk","form_set","form_section" are names that come to mind) that (following the model of from group) you would add a "section" to which in turn would hold form elements or groups. The new form function ("form_section") would also allow for a title (if folks wanted to name their sections). The form section would be a themeable so that theme developers can customize how they want the output of their forms to look, and developers can create different types of forms.

I think this would really clean up the node-form stuff, and make the html structure for forms more standardized.

If people think this is a good idea, I'd be willing to take a crack at updating the necessary pieces of node, theme, and common...

Thanks
--joshc

Comments

draw4yrlif’s picture

I've been thinking about this some more and after digging into the form generation code I've got another idea on this topic. I think I saw someone is working on a webform module...that allows people to create webforms for sending an email or storing information to a database etc.

My thinking is that we could add a new form interface that creates a form as an "object" rather than just a variable... this would allow someone to create an abstract structure of a form (completely devoid of presentation logic) we can then theme a "form" which would then loop through and theme all of its children.

Really it would be a "form factory" that would take the abstract structure of a form (which could have other uses (validation etc) and then be themed and "output" to a screen. This would further abstract the HTML development of forms form what module developers have to deal with.

Again, I'm not sure if I am the right person to do this, or if it is inline with the overall strategy for form development and handling in drupal, but I would be willing to help where I can to get this in.

--joshc

walkah’s picture

this is kind of the direction i'm heading with this... though i've not gotten heavily into the themeing aspect (yet).

check it out anyway :

http://cvs.drupal.org/viewcvs/contributions/modules/forms/

your patches and / or suggestions are very welcome.

--
James Walker :: http://walkah.net/

Dries’s picture

It is best to cook up some patches for this; maybe tackle one aspect at a time. Once we have a patch to look at, it will be easier to evaluate what you are proposing. CSS and usability improvements are much appreciated.

draw4yrlif’s picture

are there instructions on patching...I've made changes against the CVS version of Drupal. Now I just need a bit of help trying to send them to you all. Are there special instructions that I need to follow if it is multiple files? the changes I have made affect node.module, common.inc, and theme.inc. I have also modified the xtemplate theme (though that was just to test it out).

Basically what I have done is stub out a form_section function in the common.inc and the theme.inc.

common.inc

function form_section($section, $title = NULL, $section_class) {
	return theme("form_section", $section, $title, $section_class);
}

theme.inc

function theme_form_section($section, $title=NULL, $section_class=NULL) {
	$output = "";
	if ($section_class) {
		$output .= "<div class='". $section_class ."'>";

	} else {

		$output .= "<div>";
	}
	if ($title) {
		$output .= $title . "<br />";
	}
	$output .= $section;
	$output .= '</div>';
	return $output;
}

Then in the node.module I removed all of the <div> tags which were hard coded in there (which is used to distinguish between the admin section of the node form and the standard section).

Once I figure out how to get this patch done, I'd like to tackle adding form "types" so that we can get rid of the hard coded "node-form" in the node module.

Any help would be appreciated.