1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +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',
'OPTIONS' => 'OPTIONS',
'PATCH' => 'PATCH',
'CONNECT' => 'CONNECT',
'TRACE' => 'TRACE',
);
/**

View File

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

View File

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