Having trouble getting help?
Contact Support
Contact Support
Form submit in Vue Button group component
11 Jun 20244 minutes to read
The name attribute of the input element is used to group checkbox/radio type ButtonGroup. When the radio/checkbox type are grouped in form, the checked items value attribute will be post to server on form submit that can be retrieved through the name. The disabled radio/checkbox type value will not be sent to the server on form submit.
In the following code snippet, the radio type ButtonGroup is explained with male value as checked. Now, the value that is in checked state will be sent on form submit.
<template>
<div id='app'>
<form>
<div class='e-btn-group'>
<input type="radio" id="male" name="gender" value="male" checked/>
<label class="e-btn" for="male">Male</label>
<input type="radio" id="female" name="gender" value="female"/>
<label class="e-btn" for="female">Female</label>
<input type="radio" id="transgender" name="gender" value="transgender"/>
<label class="e-btn" for="transgender">Transgender</label>
</div>
<ejs-button isPrimary='true'>Submit</ejs-button>
</form>
</div>
</template>
<script setup>
import { ButtonComponent as EjsButton } from '@syncfusion/ej2-vue-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
#app {
margin: 20px;
}
.e-btn-group, button {
margin: 20px 5px 20px 20px;
}
</style>
<template>
<div id='app'>
<form>
<div class='e-btn-group'>
<input type="radio" id="male" name="gender" value="male" checked/>
<label class="e-btn" for="male">Male</label>
<input type="radio" id="female" name="gender" value="female"/>
<label class="e-btn" for="female">Female</label>
<input type="radio" id="transgender" name="gender" value="transgender"/>
<label class="e-btn" for="transgender">Transgender</label>
</div>
<ejs-button isPrimary='true'>Submit</ejs-button>
</form>
</div>
</template>
<script>
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
export default {
name: "App",
components: {
"ejs-button":ButtonComponent
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
#app {
margin: 20px;
}
.e-btn-group, button {
margin: 20px 5px 20px 20px;
}
</style>