2 john Sep 23, 2006 11:47

There's a few things in the forms class that break validation ;)
For the script, wrap it like this :-
<script type="text/javascript">
//<![CDATA[
......
......
//]]>
</script>
For the global icons etc change formstart to '<div>' and formend to '</div>' ;)
¥
Thanks ¥åßßå
I'll put the original back and use your suggestions
you'll also want to rearrange this section :-
$r .= $this->formend;
// Display all buffered hidden fields:
foreach( $this->hiddens as $hidden )
{
$r .= $hidden;
}
$r .= "\n</form>\n\n";
to :
// Display all buffered hidden fields:
foreach( $this->hiddens as $hidden )
{
$r .= $hidden;
}
$r .= $this->formend;
$r .= "\n</form>\n\n";
¥
¥åßßå
re "formstart" and "formend"
Should I change every occurrence ... to <div> and </div> ???
case 'table':
$this->formstart = '<table cellspacing="0" class="fform">'."\n";
// Note: no thead in here until you can safely add a tbody to the rest of the content...
$this->title_fmt = '<tr class="formtitle"><th colspan="2"><div class="results_title">'
.'<span class="right_icons">$global_icons$</span>'
.'$title$</div></th></tr>'."\n";
$this->no_title_fmt = '<tr><th colspan="2"><span class="right_icons">$global_icons$</span></th></tr>'."\n";
$this->fieldstart = "<tr>\n";
$this->labelstart = '<td class="label">';
$this->labelend = "</td>\n";
$this->labelempty = '<td class="label"> </td>'."\n";
$this->inputstart = '<td class="input">';
$this->infostart = '<td class="info">';
$this->inputend = "</td>\n";
$this->fieldend = "</tr>\n\n";
$this->buttonsstart = '<tr class="buttons"><td colspan="2">';
$this->buttonsend = "</td></tr>\n";
$this->formend = "</table>\n";
break;
case 'fieldset':
$this->formstart = '';
$this->title_fmt = '<span style="float:right">$global_icons$</span><h2>$title$</h2>'."\n";
$this->no_title_fmt = '<span style="float:right">$global_icons$</span>'."\n";
$this->fieldstart = "<fieldset>\n";
$this->labelstart = '<div class="label">';
$this->labelend = "</div>\n";
$this->labelempty = '';
$this->inputstart = '<div class="input">';
$this->infostart = '<div class="info">';
$this->inputend = "</div>\n";
$this->fieldend = "</fieldset>\n\n";
$this->buttonsstart = '<fieldset><div class="input">';
$this->buttonsend = "</div></fieldset>\n\n";
$this->formend = '';
break;
case 'linespan':
$this->formstart = '';
$this->title_fmt = '$title$'."\n"; // TODO: icons
$this->no_title_fmt = ''; // "
$this->fieldstart = '<span class="line">';
$this->labelstart = '';
$this->labelend = "\n";
$this->labelempty = '';
$this->inputstart = '';
$this->infostart = '';
$this->inputend = "\n";
$this->fieldend = "</span>\n";
$this->buttonsstart = '';
$this->buttonsend = "\n";
$this->formend = '';
break;
case 'blockspan':
$this->formstart = '';
$this->title_fmt = '$title$'."\n"; // TODO: icons
$this->no_title_fmt = ''; // "
$this->fieldstart = '<span class="block">';
$this->labelstart = '';
$this->labelend = "\n";
$this->labelempty = '';
$this->inputstart = '';
$this->infostart = '';
$this->inputend = "\n";
$this->fieldend = '</span>'.get_icon( 'pixel' )."\n";
$this->buttonsstart = '';
$this->buttonsend = "\n";
$this->formend = '';
break;
default:
// "none" (no layout)
$this->formstart = '';
$this->title_fmt = '$title$'."\n"; // TODO: icons
$this->no_title_fmt = ''; // "
$this->fieldstart = '';
$this->labelstart = '';
$this->labelend = "\n";
$this->labelempty = '';
$this->inputstart = '';
$this->infostart = '';
$this->inputend = "\n";
$this->fieldend = "\n";
$this->buttonsstart = '';
$this->buttonsend = "\n";
$this->formend = '';
}
}
You can if you like (just the "empty" ones), but I only change the fieldset one as that's the "default" on my blog. It certainly won't "harm" things if you do ;)
¥
Thanks mate
No problem ;)
¥
Ok, now the only "strict validation" issue is
there is no attribute "name"
<form name="bComment_form_id_904" id="bComment_form_id_904" class="bComment" method="post" action="http://yoururl.com/htsrv/comment_post.php">
ahhh, that's a skin thing, _feedback.php
$Form = & new Form( $htsrv_url.'comment_post.php' );
;)
¥
Bingo :)
Your so good your dangerous ¥åßßå :)
I spent ages poking around everywhere else ...
¥åßßå wrote:
ahhh, that's a skin thing, _feedback.php
$Form = & new Form( $htsrv_url.'comment_post.php' );
;)
¥
Not so fast.. now the form has no ID anymore (which is required for JS for example). The problem is that the Form class adds both id and name attribs to the FORM tag, but that's fixed for 1.9 already. And if you want to fix it for 1.8, you're better off to fix it there, too.. :)
¥åßßå wrote:
you'll also want to rearrange this section :-
$r .= $this->formend; // Display all buffered hidden fields: foreach( $this->hiddens as $hidden ) { $r .= $hidden; } $r .= "\n</form>\n\n";
to :
// Display all buffered hidden fields: foreach( $this->hiddens as $hidden ) { $r .= $hidden; } $r .= $this->formend; $r .= "\n</form>\n\n";
¥
So that the HIDDEN INPUTS are in a container, right?
But it will probably fail for the "table" type form, because you'll then get the hidden inputs between the closing TR and the closing TABLE and that's probably invalid.
John, where have you seen $global_icon$?
@¥åßßå: I've just committed some CDATA fixes. Thanks.
blueyed wrote:
So that the HIDDEN INPUTS are in a container, right?
But it will probably fail for the "table" type form, because you'll then get the hidden inputs between the closing TR and the closing TABLE and that's probably invalid.
Yep, and it would fail on the table type, so it would be better to just wrap them in their own div :-
$r .= '<div>';
// Display all buffered hidden fields:
foreach( $this->hiddens as $hidden )
{
$r .= $hidden;
}
$r .= '</div>';
¥
Shouldn't there be a global DIV then better inside of the Form?
Because e.g. with type "inline" the inline inputs would be invalid (not wrapped). OTOH a DIV (also only for the hiddens) could have layout issued, when the form is not supposed to be displayed as a block element.
blueyed
It's not that I see it
It's that there is always the empty span error...
<span style="float:right"></span>
however it now validates with the div wraps
personally I'd wrap the whole form (regardless of formstart & form end) as :-
<form ........>
<div>
.......
......
</div>
</form>
¥
John, the empty warning can be ignored and have nothing to do with the validator, but with tidy complaining about it - you're probably using the Firefox Validator plugin, I guess.
¥åßßå, yes that makes sense. I'll do it that way, but with an explicit "display:inline" in there.
Thanks guys
Thanks for reporting.. ;)
Ok, I restored everything , including the _feedback.php
Uploaded the new _form.class.php from the CVS and it validates fine.
@blueyed, yes, Tidy is only just lightweight "lint collector" when it comes to validation and often conflicts with W3C Validator. :)
@blueyed
In the new CVS update for _form.class.php you have..
if( is_object($AdminUI) )
{ // Get default skin setting:
$template = $AdminUI->get_template( 'Form' );
This gives errors in the Admin screens which disappear when it's changed back to ...
if( is_object($AdminUI) )
{ // Get default skin setting:
$template = $AdminUI->get_menu_template( 'Form' );
I don't have a clue what it should be so I'm just bringing it to your attention
Cheers
John
John, you've downloaded the version from CVS HEAD, which will become 2.0 and this method has been renamed.
Try the Form class for version 1.9 instead: http://evocms.cvs.sourceforge.net/evocms/b2evolution/blogs/inc/_misc/_form.class.php?view=markup&pathrev=v-1-9
Thanks for that blueyed.'
It's easy ( for me ) to get lost in the CVS :)
@blueyed
Ummm... it's also the same in the 1.9 CVS
// Get default skin setting:
$template = $AdminUI->get_template( 'Form' );
$layout = $template['layout'];
Then you have to manually rename them locally in your _form.class.php.. :)
Well, I deleted it from _forms.class.php and the roof didn't fall in?
Another is the javascript.. where the two "&"'s should maybe be