Bug #6202

ActionViewHelper breaks html on empty content

Added by Georg Ortner over 12 years ago. Updated over 11 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
0.50 h
Has patch:


It's not really a bug, but to me it's not very well designed.

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):


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.



Updated by Robert Lemke about 12 years ago

  • Target version changed from 1.0.0 alpha 7 to 1.0.0 alpha 8

Updated by Bastian Waidelich almost 12 years ago

  • Category set to ViewHelpers
  • Status changed from New to Rejected
  • Target version deleted (1.0.0 alpha 8)
  • Branch set to v4 + v5

Hi Georg and sorry for the late reaction ;)
You're right,*$this->tag->forceClosingTag(true);* would be the solution for this. But I don't agree to change this actually..
The anchor tag is allowed to be self-closing (in contrast to the script tag for example). So self-closing a-tags if there is no content seems to be the correct behavior to me. And it is XHTML-valid either.

I'm taking the liberty to close this issue for now. If you don't agree or want to discuss this further, please re-open!

Thanks for your feedback.

Also available in: Atom PDF