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

Conditional fields #156

Open
illumws opened this issue Sep 17, 2019 · 1 comment
Open

Conditional fields #156

illumws opened this issue Sep 17, 2019 · 1 comment

Comments

@illumws
Copy link

illumws commented Sep 17, 2019

How can I make conditional fields
(I searched the documentation and I didn't find it)

I am Brazilian, here people and companies have diferent documents for each one (CPF, CNPJ)
respectively, but only chage the masks and the max numbers,
how can I create a field where I select the type of registration using a radio and exchange the subsequent input

@illjah42
Copy link
Contributor

Hi, @AlessandroAmos. Try something like this:

<form-builder url="/api/endpoint" :default="{tax: 'CPF'}">
    <template #default="fields">
        <fb-radio-group name="tax" :items="['CPF', 'CNPJ']"></fb-radio-group>
        <fb-input
            label="Document
            name="doc"
            :mask="fields.tax === 'CPF' ? '###.###.###-##' : '##.###.###/####-##'"
            v-tooltip="fields.tax === 'CPF' ? 'format: 123.456.789-00' : 'format: 12.345.678/0001-09'"
        ></fb-input>
     </template>
</form-builder>

Did it help?

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

2 participants