netojose / laravel-bootstrap-4-forms

Bootstrap 4 forms for Laravel 5/6/7/8
MIT License
183 stars 58 forks source link

Setting button ID via chainable method is ignored #113

Open gavinsbtm opened 2 years ago

gavinsbtm commented 2 years ago

Adding an ID to a button element using chainable id method is ignored.

Eg: Form::button('Upload')->id('upload-btn')

Output is: <button type="button" class="btn btn-primary">Upload</button>

Expected output: <button id="upload-btn" type="button" class="btn btn-primary">Upload</button>

Changing renderButton() function in FormBuilder.php fixes this:

private function renderButton(): string
    {
        extract($this->get('id', 'type', 'value', 'disabled'));
        $class = $this->getBtnAnchorClasses();
        $attrs = $this->buildHtmlAttrs(['id' => $id, 'type' => $type, 'class' => $class, 'disabled' => $disabled]);
        return '<button ' . $attrs . '>' . $value . '</button>';
    }