Panel | no textarea in a custom modal form

Hi,
I made a custom tag “question”. For this I registred a custom button with a modal form.
It works fine. Only one behavior I dont understand. Why I can not use a textarea in my custom form?
If I try, i get this error:

“Method Buttons::__toString() must not throw an exception, caught Error: Call to a member function url() on null”

All other fieldtypes are working. Here is, what I did:

fields/textarea/forms/question.php

<?php 
return function($page, $textarea) {
    $form = new Kirby\Panel\Form(array(
    'question' => array(
          'label'       => 'Frage',
          'type'        => 'text',// textarea doesnt work
          'placeholder' => '???',
          'autofocus'   => 'true',
          'required'    => 'true',
    ),
    'answer' => array(
          'label' => 'Antwort',
          'type'  => 'text', // textarea doesnt work
    
    ),
    'h' => array(
          'label' => 'h',
          'type'  => 'number',// textarea doesnt work
     )      
    ));

  $form->data('textarea', 'form-field-' . $textarea);
  $form->style('editor');
  $form->cancel($page, 'show');

  return $form;
};

Do you have any ideas? Thank you.

1 Like

I have little experience with custom panel extensions, but it sounds to me like Kirby’s textarea component needs to have some sort of buttons setting when created manually - like when you want to customized your textarea in a blueprint https://getkirby.com/docs/cheatsheet/panel-fields/textarea#customizing-buttons .

1 Like

Thank you for your tip. Now it works with buttons: false. That’s great for my purpose.
buttons: true does not work.

fields/textarea/forms/question.php

<?php
return function($page, $textarea) {

$form = new Kirby\Panel\Form(array(
    'question' => array(
        'label' => 'Frage',
        'icon' => 'question-circle',
       'type' => 'textarea',
        'buttons' =>  false ,  
        'placeholder' => 'Frage?',
        'autofocus' => 'true',
        'required' => 'true',
    ),
    'answer' => array(
        'label' => 'Antwort',
        'icon' => 'exclamation',
        'type' => 'textarea',
        'buttons' =>  false ,
        'placeholder' => 'Antwort.',
    ),
    'h' => array(
        'label' => 'Größe (1-6)',
        'icon' => 'header',
        'type' => 'number',  
        'min' => 1,
        'max' => 6
    )
));

$form->data('textarea', 'form-field-' . $textarea);
$form->style('editor');
$form->cancel($page, 'show');

return $form;

};

Thank you! André