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:
@@ -113,6 +113,8 @@ class WireInput extends Wire {
|
||||
'DELETE' => 'DELETE',
|
||||
'OPTIONS' => 'OPTIONS',
|
||||
'PATCH' => 'PATCH',
|
||||
'CONNECT' => 'CONNECT',
|
||||
'TRACE' => 'TRACE',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -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'])) {
|
||||
|
@@ -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');
|
||||
|
Reference in New Issue
Block a user