1<?php 2/** 3 * Class for <input type="hidden" /> elements 4 * 5 * PHP version 5 6 * 7 * LICENSE 8 * 9 * This source file is subject to BSD 3-Clause License that is bundled 10 * with this package in the file LICENSE and available at the URL 11 * https://raw.githubusercontent.com/pear/HTML_QuickForm2/trunk/docs/LICENSE 12 * 13 * @category HTML 14 * @package HTML_QuickForm2 15 * @author Alexey Borzov <avb@php.net> 16 * @author Bertrand Mansion <golgote@mamasam.com> 17 * @copyright 2006-2021 Alexey Borzov <avb@php.net>, Bertrand Mansion <golgote@mamasam.com> 18 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License 19 * @link https://pear.php.net/package/HTML_QuickForm2 20 */ 21 22/** 23 * Base class for <input> elements 24 */ 25require_once 'HTML/QuickForm2/Element/Input.php'; 26 27/** 28 * Class for <input type="hidden" /> elements 29 * 30 * @category HTML 31 * @package HTML_QuickForm2 32 * @author Alexey Borzov <avb@php.net> 33 * @author Bertrand Mansion <golgote@mamasam.com> 34 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License 35 * @version Release: 2.2.2 36 * @link https://pear.php.net/package/HTML_QuickForm2 37 */ 38class HTML_QuickForm2_Element_InputHidden extends HTML_QuickForm2_Element_Input 39{ 40 protected $attributes = ['type' => 'hidden']; 41 42 /** 43 * Hidden elements can not be frozen 44 * 45 * @param bool $freeze Whether element should be frozen or editable. This 46 * parameter is ignored in case of hidden elements 47 * 48 * @return bool Always returns false 49 */ 50 public function toggleFrozen($freeze = null) 51 { 52 return false; 53 } 54 55 /** 56 * Disallows setting an error message on hidden elements 57 * 58 * @param string|null $error 59 * 60 * @return HTML_QuickForm2_Element_InputHidden 61 * @throws HTML_QuickForm2_InvalidArgumentException if $error is not empty 62 */ 63 public function setError($error = null) 64 { 65 if (strlen($error)) { 66 throw new HTML_QuickForm2_InvalidArgumentException( 67 "Hidden elements cannot have validation errors" 68 ); 69 } 70 return parent::setError($error); 71 } 72 73 public function render(HTML_QuickForm2_Renderer $renderer) 74 { 75 $renderer->renderHidden($this); 76 $this->renderClientRules($renderer->getJavascriptBuilder()); 77 return $renderer; 78 } 79} 80?> 81