I want text input not textarea (v.3)

Hi!
I got lot of fields in db defined as text and when creating a form it is all rendered as <textarea>.
I know I can add ['type' => "text"] to all inputs, but I want something for all view.
I tried:

$this->loadHelper('Form', [
    'widgets' => [
        'text' => ['Basic'],
        
    ],
]);

but it didn’t helped. I use it for switch off datetime widget and use HTML one.

Have you tried this?

$this->loadHelper( 'Form', [
  'typeMap' => [
    'text' => 'text',
  ]
] );

basically there is a typeMap array present in the default FormHelper which maps the type of the form element to its template.
https://github.com/cakephp/cakephp/blob/3.x/src/View/Helper/FormHelper.php#L85

And you can overwrite/adjust those config values while loading your helper.

Another possibility would be to overwrite the default textarea template completely. See Form - 4.x

1 Like

Or change those columns to varchar? The assumption Cake is making here is that if you’ve defined your column as text, it’s because it’s to potentially hold a LOT of data, more than can be comfortably edited in a single line, so it goes to a textarea. A varchar indicates that it’s shorter, so Cake uses the shorter input field.

Thanks @KevinPfeifer , it works!.
@Zuluru we made some bad choices in data types few years ago and now it got its time for revenge :wink:

It’s never too late to fix past mistakes!