cpuser
October 3, 2023, 9:35am
1
I have a checkbox, but would like to use Bootstrap Switch.
I can’t get it to work. Its dynamic, to pick up the value when = 1
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault">
<label class="form-check-label" dmx-bind:for="insp_pck_status_{{$index}}">Default switch checkbox input</label>
</div>
karh
October 3, 2023, 10:28am
2
I’m not 100% sure what you want to do.
But try add:
value="1"
To the <input>
This will send a value of 1 when you submit the form. Note:When the switch is unchecked it won’t send any value.
Teodor
October 3, 2023, 10:33am
3
It’s not really clear what are you trying to do. Please explain a bit more detailed.
Also, when posting code make sure to format it as explained here:
Code Formatting
When pasting code in your posts, please use the following formatting options, in order to be sure your code is readable and well formatted for the rest of the users.
Inline code formatting
Surround a section of code with backticks (`) inline code formatting.
Typing:
`var x = 10;`
Results in:
var x = 10;
This can also be done as var x = 10; inline.
Multi-Line Blocks of Code
Surrounding code with three backticks ``` will allow for code to span multiple lines
Typing:
```
f…
1 Like
try:
<input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault" dmx-on:changed="flexSwitchCheckDefault.setValue(checked?1:0)">
2 Likes
1.Just give the switch a static value of 1
2. Set checked in dynamic attributes to your switch value being equal to 1
3 In your server action add a default value of 0 to deal with when the switch is unchecked and hasn’t a value
2 Likes