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

UiSwitch: Submit value when not on #485

Open
EmilMoe opened this issue Jan 6, 2020 · 3 comments
Open

UiSwitch: Submit value when not on #485

EmilMoe opened this issue Jan 6, 2020 · 3 comments

Comments

@EmilMoe
Copy link
Contributor

EmilMoe commented Jan 6, 2020

I'm missing a property for submittedFalseValue or something as now it's just ignored.

@EmilMoe
Copy link
Contributor Author

EmilMoe commented Jan 6, 2020

@JosephusPaye
Copy link
Owner

Yeah this is an issue I've faced myself. Would it be better solved though outside of Keen UI? E.g. add the hidden input as recommended in that StackOverflow answer next to the use of <ui-switch></ui-switch>?

@EmilMoe
Copy link
Contributor Author

EmilMoe commented Jan 8, 2020

I am not sure. But the use case for me was that I expected to always submit a value so others might expect it too? The solution could be that submit-false-value to only include it when explicit wanting to in order not to manipulate the semantics per default.

I have created a wrapper component which you are welcome to get inspirations from, it will always submit a value, either 1 or 0 as this is what works for my specific project:

<template>
    <div>
        <ui-switch
                :name="name"
                :label="label"
                v-model="value"
                true-value="1"
                false-value="0"
                submitted-value="1">
            <slot></slot>
        </ui-switch>
        <input
                v-if="value === '0'"
                type="hidden"
                :name="name"
                value="0">
    </div>
</template>

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

No branches or pull requests

2 participants