nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.

Home Page:https://doc.nette.org/forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addText/addPassword - wrong parameter name?

Gappa opened this issue · comments

Version: master

Bug Description

Both addText and addPassword methods have a third optional parameter named cols which is then passed to the TextInput control under the correct HTML attribute name size.

I think it should be renamed to be more intuitive in regards to PHP named arguments introduced in PHP 8.

Steps To Reproduce

Here's the code for both methods:

  • public function addText(string $name, $label = null, int $cols = null, int $maxLength = null): Controls\TextInput
    {
    return $this[$name] = (new Controls\TextInput($label, $maxLength))
    ->setHtmlAttribute('size', $cols);
    }
  • public function addPassword(
    string $name,
    $label = null,
    int $cols = null,
    int $maxLength = null
    ): Controls\TextInput {
    return $this[$name] = (new Controls\TextInput($label, $maxLength))
    ->setHtmlAttribute('size', $cols)
    ->setHtmlType('password');
    }

Expected Behavior

The parameter is named size instead of cols.

Possible Solution

Rename the parameter.


Should I prepare a PR? :)

It's intentional, I think cols is more concise than universal size and consistent with cols & rows in addTextArea.

Above all, I want to remove that parameter in the next version.

Well, it depends whether you want to be consistent with the rest of the Forms API or with the legacy HTML attribute :)

Since it's intentional and in fact not a big deal (I've never used that parameter ever), I'm closing it.