I was wondering how I could change the HTML of the textareas in the panel.
I do know that I can make custom form fields. But I don’t know how to change the HTML of for example the textareas. What I did was copying the default textarea. How can I change the html of this? Maybe adding a class would be enough
And I also see that there is an element that wraps the input (it has an $element variable). Would I be able to change the HTML of this element? For instance add a <h2> or perhaps even an <img> tag in it?
The you would have to modify in the element(). method, for example:
public function element() {
$element = parent::element();
$element->addClass('field-with-textarea');
if($this->buttons and !$this->readonly) {
$element->addClass('field-with-buttons');
}
$headline = new Brick('h2', 'Some headline'); // create a new h2 element
$element->append($headline); // append to the element
return $element;
}
Still interested in learning what your use case is…
Yes, you can do all that, instead of calling the parent, you can create your own wrapper and totally modify. it. Check out the source code. and that. of the. parent class how it works.