[TYPO3-dev] ViewHelper Translate Labels

Bernd Schönbach bs.newsfeeds at googlemail.com
Fri Dec 30 14:02:50 CET 2011


Hi,

is there a way to write a custom view helper, which can translate the 
give argument?

E.g. I have a view helper which extends the select options with a dummy 
field and want the dummy option to have a translatable label.

Thanks
Bernd

Here is the ViewHelper code:

	/**
	 * Initializes some arguments
	 */
	public function initializeArguments() {
		parent::initializeArguments();
		$this->registerArgument('additionalOptions', 'array', 'Associative 
array with values to prepend', FALSE);
	}

	/**
	 * Retrieves the options for the select box
	 *
	 * @return array the options to display, will be empty if no options 
were given
	 */
	protected function getOptions() {
		$options = parent::getOptions();
		if(empty($this->arguments['additionalOptions'])) {
			return $options;
		}
		foreach ($this->arguments['additionalOptions'] as $key => $value) {
			$additionalOptions[$key] = $value;
		}
		return $additionalOptions + $options;
	}
}


Original Source of this code is here: 
http://www.npostnik.de/typo3/fluid-select-in-formularen-mit-weiteren-optionen/comment-page-1/#comment-9906



More information about the TYPO3-dev mailing list