[FLOW3-general] Fluid: ActionViewHelper

Georg Ortner go at simplaweb.at
Mon Jan 25 12:01:26 CET 2010


If we do something like:

<f:link.action action="index">{blog.title}</f:link.action>

And blog.title is empty we would get:

<a href="someUri" otherAttributes="" />

Because right now if there is no content given to a ActionViewHelper it 
assumes that we don't need a closing tag. This ends up in a broken html.

Of course a link-tag without content doesn't make much sense but I think 
this can happen easily.

This decision is taken in Fluid/Core/ViewHelper/TagBuilder at line 222

if ($this->hasContent() || $this->forceClosingTag) {
	$output .= '>' . $this->content . '</' . $this->tagName . '>';
} else {
	$output .= ' />';
}

So far I think there are two possible solutions:

1) We add the following to ActionViewHelper, EmailViewHelper and 
ExternalViewHelper (and all featured TagBasedViewHelpers which do need 
the closing tag):

$this->tag->forceClosingTag(true);

2) We make forceClosingTag default true in TagBasedViewHelper and take 
care that every child of this class which doesn't need a closing tag 
sets it on false.


Personally I prefer second because I think the number of 
TagBasedViewHelpers which do need the closing tag is greater than the 
others.


For now if you use the ActionViewHelper make sure that you have at least 
a blank as content:

<f:link.action ...>{blog.title} </f:link.action>


Regards



More information about the FLOW3-general mailing list