1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 01:34:31 +02:00

Add support for the initValue property to InputfieldTextarea. Previously it was present as an option but didn't work.

This commit is contained in:
Ryan Cramer
2021-10-08 15:54:58 -04:00
parent aa4fbd4dd9
commit 511a068b69
3 changed files with 13 additions and 6 deletions

View File

@@ -113,6 +113,8 @@ class WireInput extends Wire {
'DELETE' => 'DELETE', 'DELETE' => 'DELETE',
'OPTIONS' => 'OPTIONS', 'OPTIONS' => 'OPTIONS',
'PATCH' => 'PATCH', 'PATCH' => 'PATCH',
'CONNECT' => 'CONNECT',
'TRACE' => 'TRACE',
); );
/** /**

View File

@@ -134,8 +134,10 @@ class InputfieldText extends Inputfield {
} }
} }
if(!strlen($attrs['value']) && $this->initValue) { if($this->initValue) {
$attrs['value'] = $this->initValue; if(!strlen($attrs['value'])) {
$attrs['value'] = $this->initValue;
}
} }
if(isset($attrs['minlength'])) { if(isset($attrs['minlength'])) {

View File

@@ -86,11 +86,12 @@ class InputfieldTextarea extends InputfieldText {
public function ___render() { public function ___render() {
$attrs = $this->getAttributes(); $attrs = $this->getAttributes();
$value = $attrs['value'];
unset($attrs['value'], $attrs['size'], $attrs['type']); unset($attrs['value'], $attrs['size'], $attrs['type']);
$out = $out =
"<textarea " . $this->getAttributesString($attrs) . ">" . "<textarea " . $this->getAttributesString($attrs) . ">" .
htmlspecialchars($this->value, ENT_QUOTES, "UTF-8") . htmlspecialchars($value, ENT_QUOTES, "UTF-8") .
"</textarea>"; "</textarea>";
return $out; return $out;
} }
@@ -171,9 +172,11 @@ class InputfieldTextarea extends InputfieldText {
public function ___getConfigInputfields() { public function ___getConfigInputfields() {
$inputfields = parent::___getConfigInputfields(); $inputfields = parent::___getConfigInputfields();
$inputfields->remove($inputfields->getChildByName('size')); // size is not applicable to textarea $removes = array('size', 'pattern');
$inputfields->remove($inputfields->getChildByName('pattern')); // pattern is not applicable to textarea foreach($removes as $name) {
//if($this->hasFieldtype !== false) $inputfields->remove($inputfields->get('maxlength')); $f = $inputfields->getChildByName($name);
if($f) $inputfields->remove($f);
}
/** @var InputfieldInteger $field */ /** @var InputfieldInteger $field */
$field = $this->modules->get('InputfieldInteger'); $field = $this->modules->get('InputfieldInteger');