Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv-checkbox it is impossible to pass attribute name="" #1492

Open
Skro11-ru opened this issue Jul 28, 2023 · 2 comments
Open

cv-checkbox it is impossible to pass attribute name="" #1492

Skro11-ru opened this issue Jul 28, 2023 · 2 comments

Comments

@Skro11-ru
Copy link

This code

<cv-checkbox
    :label="'someLabel'"
    :value="'someValue'"
    name="someName"
>
</cv-checkbox>

generates the following HTML

<div class="cv-checkbox bx--checkbox-wrapper bx--form-item">
    <input type="checkbox"
           id="uid-c26932a9-2e22-45e1-a5ef-ce867a33254a"
           class="bx--checkbox"
           value="someValue"
    >
    <label
            for="uid-c26932a9-2e22-45e1-a5ef-ce867a33254a"
            class="bx--checkbox-label"
    >
        <span class="bx--checkbox-label-text"> someLabel </span>
    </label>
</div>

Thus, it is impossible to pass the name attribute to the cv-checkbox component, which is quite sad.
Is this a bug or am I doing something wrong?

@davidnixon
Copy link
Collaborator

That seems like it should work. Checking ...

@atleta
Copy link

atleta commented Sep 22, 2023

The reason it doesn't work is because checkMixin (packages/core/src/mixins/check-mixin.js) defines name as a prop and cv-checkbox does not add it to the input field explicitly but uses v-bind="$attrs". However, $attrs only contains the attributes that are not defined as props (which name is) or in the emits option.

See

and

It's interesting, because it seems that this bug has been there since the very first version of this compoments (March 2019) and it prevents submitting the value of the checkbox from a form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants