<?php

/**
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package fusionLib
 * @copyright Copyright (c) 2011 - 2013 fusionLib. All rights reserved.
 * @link http://fusionlib.com
 */

/**
 * flFormDecoratorFieldset Class
 *
 * Form decorator wrapping content in a fieldset.
 *
 * @package fusionLib
 */
class flFormDecoratorFieldset extends flFormDecorator {
	/**
	 * Decorate an element.
	 *
	 * @param flFormElement $elem The element to decorate.
	 * @param string $content The content for the element e.g. <input ...>
	 * @return string The decorated element
	 */
	function decorate($elem, $content) {
		$r = "<fieldset id=\"" . $elem->getName() . "-group\">\n";
		if(($label = $elem->getLabel()) !== null)
			$r .= "<legend>$label</legend>\n";
		return $r . "$content</fieldset>\n";
	}
}
