mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 00:06:55 +02:00
Add option for InputfieldHidden to still render as an input in renderValue mode
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
/**
|
||||
* An Inputfield for handling XHTML "hidden" form inputs
|
||||
*
|
||||
* @property bool $renderValueAsInput Render the hidden input, even when in renderValue mode (default=false)
|
||||
*
|
||||
*/
|
||||
class InputfieldHidden extends Inputfield {
|
||||
|
||||
@@ -18,6 +20,7 @@ class InputfieldHidden extends Inputfield {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->setAttribute('type', 'hidden');
|
||||
$this->set('renderValueAsInput', false);
|
||||
$this->initValue = '';
|
||||
}
|
||||
|
||||
@@ -25,6 +28,14 @@ class InputfieldHidden extends Inputfield {
|
||||
return "<input " . $this->getAttributesString() . " />";
|
||||
}
|
||||
|
||||
public function ___renderValue() {
|
||||
if($this->renderValueAsInput) {
|
||||
return $this->render();
|
||||
} else {
|
||||
return parent::___renderValue();
|
||||
}
|
||||
}
|
||||
|
||||
public function getAttributes() {
|
||||
$attrs = parent::getAttributes();
|
||||
if(!strlen($attrs['value']) && $this->initValue) $attrs['value'] = $this->initValue;
|
||||
|
Reference in New Issue
Block a user