Suggestion #6301 Possibility to add an emptyOption

Added by Susanne Moog over 12 years ago. Updated over 8 years ago.

Could have
Start date:
Due date:
% Done:


Estimated time:
Has patch:


It would be nice to have an emptyOption as attribute for the view helper.

So you could write

< property="category" options="{categories}"
optionLabelField="name" size="1" id="category" emptyOption="- none -" />

and generate:
<select name="category" size="1" id="category">
<option value="">- none -</option>
<option value="cat1">cat1</option>
<option value="cat2">cat2</option>
<option value="cat3">cat3</option>

I implemented it with adding in selectViewHelper lines 210 ff (FLOW3 a7 version) these lines:
if ($this->arguments->hasArgument('emptyOption')) {
$options = array('' => $this->arguments['emptyOption']) + $options;

and registering it in the initializeArguments method:
$this->registerArgument('emptyOption', 'string', 'If specified, an empty option will be added with the given string as label.');

I can't currently provide a real patch, as I have no svn version here, sorry :(


emptyOption.diff (1.62 KB) emptyOption.diff Henjo Hoeksma, 2010-10-26 11:49
issue_6301.diff (2.07 KB) issue_6301.diff Pascal Dürsteler, 2012-10-09 09:55

Updated by Susanne Moog over 12 years ago

I should have additionally mentioned that the code above just gives the possibility to add the empty option. You will most likely get an error if you try to save it, so the saving part is still missing.


Updated by Peter Niederlag about 12 years ago

adding an Idea from Jochen:

strip "semantics" off the argument. Two options "appendOption" and "prependOption" seems to be cleaner.

This feature is quite often needed in reallife IMO.


Updated by Bastian Waidelich almost 12 years ago

  • Project changed from TYPO3.Fluid to Fluid - ViewHelper - Incubator
  • Category deleted (ViewHelpers)

Updated by Bastian Waidelich almost 12 years ago

  • Subject changed from Possibility to add an emptyOption to the view helper to Possibility to add an emptyOption

Updated by Henjo Hoeksma over 11 years ago

attached a patch that provides a solution Susanne considered. It provides an argument 'prependOption'. The value of the argument is the label of the valueless option tag.


Updated by Alex Kellner about 11 years ago


Thx, sounds like a nice hack, but only a hack at the moment :(


Updated by Bastian Waidelich almost 11 years ago

  • Tracker changed from Feature to Suggestion

Updated by Thomas Löffler over 10 years ago


What's the status of this issue? Any problems? Or any dissonances?


Updated by Grummfy over 10 years ago

on typo3 4.5.4, to save it correctly I need to replace
$options = array('' => $this->arguments['emptyOption']) + $options;
by this
$options = array('-1' => $this->arguments['emptyOption']) + $options;

And it works


Updated by Dominic Garms about 10 years ago


I would love to see this feature merged into fluid, because this is very often required in search form fields. +1


Updated by Pascal Dürsteler over 9 years ago

+1, I count this as a basic requirement.

Personally, I'd do it like this:

includeBlank="--- Choose ---"

which gives you the possibility to either include a blank one with no text or a defined text/translation.

Jochen's idea posted by Peter Niederlag seems nice, however I don't see the benefit of adding something at the end of a select. If you have to add something, that would be at the top.


Updated by Pascal Dürsteler over 9 years ago

Adding diff which introduces


to the select view helper. Also introduces a little change to the extbase mapper to treat '' values as NULL values which already is in the code, but not for numeric/arrays, which is required here. This also prevents the discussed error above.


Updated by Pascal Dürsteler about 9 years ago

Looks like this can be closed because of


Updated by Bastian Waidelich about 9 years ago

  • Status changed from New to Closed
  • Has patch set to No

Pascal Dürsteler wrote:

Looks like this can be closed because of

Right. Although this still needs to be "forward ported" to Flow

Also available in: Atom PDF