Template thoughts concerning forms - please comment
Ok, as folks know, I've been stuck for a bit on the whole template engine because I wasn't sure how to handle forms. I think I have a solution and I'd like feedback.
Consider the Add Comment process. In core BlogCFC, this involves launching a popup window. You enter your comment, save it, and the popup closes and the main window reloads. Other folks have modified this. They either use a comment form on the page itself, or they do it but hide the form display with JavaScript.
My thinking is this. While I can see folks wanting control over how the form shows up, and control over the fonts used in the form, I can't see them wanting control over the layout of the fields. So for example, the first fields asks for your name, the second your email address, and so on. I don't think folks would care to switch email and website.
So to handle the comment form, your template will simply use a token like so: %commentform%. That one tag will be replaced with the form. It will also handle displaying the errors. The output will be standardized, so you know exactly what CSS to modify if you want different fonts. This means you can change the basic layout, like padding, etc. You just wouldn't be able to change the order of stuff. Or change that errors show on top. I think this is a fine compromise. The only detail I'm a bit unsure of is how to handle success. Right now on success we do: reload opener, close window. But for folks who want a different type of 'Add Comment' logic, I'll need to think I'm a bit more. I may just use one more file for comment completion. This file would be run when stuff is done.
Anyway - thoughts please? This was the last thing holding me up before I wrapped the prototype.
Though it's not directly your question, here's my thought on how the form might work: To me, it would be nice to have an add comment form appear on the same page such as with an iFrame (for instance). That way the default is that you can see other comments while drafting your own.
In some of my blogs i've used the mootools Fx.Slide function
var mySlide1 = new Fx.Slide('comment1');
$('toggle1').addEvent('click', function(e){
e = new Event(e);
mySlide1.toggle();
e.stop();
});
mySlide1.hide();
Then the comments box appears but it's hidden until someone clicks "add comment".