<?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) 2012 - 2013 fusionLib. All rights reserved.
 * @link http://fusionlib.com
 */

/**
 * flFormElementUri Class
 *
 * HTML5 url input field.
 *
 * @package fusionLib
 */
class flFormElementUri extends flFormElementText {

	/**
	 *	Construct the element.
	 *
	 *	@param flForm $form The form the element will be used with or null if not using flForm
	 *	@param string $name The name of the element.
	 *	@param string $default The default value of the element.
	 */
	function __construct($form, $name, $default = null) {
		parent::__construct($form, $name, $default);
		$this->addValidator(new flFormValidatorUri());
	}

	/**
	 * Draw the element.
	 *
	 * @return string Element HTML.
	 */
	function render() {
		$html = "<input type=\"url\" id=\"$this->name\" name=\"$this->name\" value=\"" . $this->_getValueEscaped() . '"';
		if($this->maxLength !== null) $html .= " maxlength=\"$this->maxLength\"";
		return $html . $this->attribHTML() . " />\n";
	}
}
