/Nette/Forms/Controls/HiddenField.php
PHP | 85 lines | 26 code | 21 blank | 38 comment | 0 complexity | f1e052e023a68e5924954415530869ff MD5 | raw file
Possible License(s): BSD-3-Clause
- <?php
- /**
- * Nette Framework
- *
- * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- *
- * This source file is subject to the "Nette license" that is bundled
- * with this package in the file license.txt.
- *
- * For more information please see http://nettephp.com
- *
- * @copyright Copyright (c) 2004, 2009 David Grudl
- * @license http://nettephp.com/license Nette license
- * @link http://nettephp.com
- * @category Nette
- * @package Nette\Forms
- */
- /*namespace Nette\Forms;*/
- require_once dirname(__FILE__) . '/../../Forms/Controls/FormControl.php';
- /**
- * Hidden form control used to store a non-displayed value.
- *
- * @author David Grudl
- * @copyright Copyright (c) 2004, 2009 David Grudl
- * @package Nette\Forms
- */
- class HiddenField extends FormControl
- {
- /** @var string */
- private $forcedValue;
- public function __construct($forcedValue = NULL)
- {
- parent::__construct();
- $this->control->type = 'hidden';
- $this->value = (string) $forcedValue;
- $this->forcedValue = $forcedValue;
- }
- /**
- * Bypasses label generation.
- * @return void
- */
- public function getLabel($caption = NULL)
- {
- return NULL;
- }
- /**
- * Sets control's value.
- * @param string
- * @return HiddenField provides a fluent interface
- */
- public function setValue($value)
- {
- $this->value = is_scalar($value) ? (string) $value : '';
- return $this;
- }
- /**
- * Generates control's HTML element.
- * @return Nette\Web\Html
- */
- public function getControl()
- {
- return parent::getControl()->value($this->forcedValue === NULL ? $this->value : $this->forcedValue);
- }
- }