Specifying Number of Rows in Control() Select

Thought this would be easy but has proven to be perplexing. I’m trying to increase the number of rows displayed in a control() select list. I was hoping it would be an option something like using rows=> in a textarea() but no such luck.

Looks like the default is 4 rows. Any way to increase this?


This works for me

echo $this->Form->control( 'comments', [
  'class'        => 'js-tinymce',
  'rows'         => 10,
  'templateVars' => [
    'size'    => 'l-col-60',
    'icon'    => 'text_fields',
    'tooltip' => __( 'Other information, that cannot be saved otherwise.' )
] );

where templateVars are custom variables I use in custom from templates.
Please check Form - 4.x for more details on how to make your own templates

As a test, I did try using the ‘rows’ option with no luck. Your example looks like it’s defining a text area which the rows option does work for. A simple example of what I’m trying to do is:

echo $this->Form->control(‘certifications._ids’, [
‘options’ => $certifications,
‘label’ => false,
‘multiple’ => true

When this presents, I would really like to have it be a 6 line select field (or more) rather than a 4.

I think the relevant attribute for the select control is “size”, not “rows”.

Perfect. That worked. I don’t see that option anywhere in the documentation. Thanks for the help.

It’s not really a Cake specific thing. It’s one of many HTML attributes that can be put on things. Anything that Cake doesn’t have a specific knowledge of, it just passes through unchanged.

Oh sorry, I misunderstood your question. I thought the rows attribute didn’t work for you when outputting a textarea :sweat_smile:

No worries. I had not thought about injecting the HTML attributes as Zuluru suggested. Thanks again.