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

Improve Input Switch component #1317

Merged
merged 4 commits into from
Nov 9, 2024
Merged

Conversation

dfsmania
Copy link
Collaborator

@dfsmania dfsmania commented Nov 2, 2024

Question Answer
Pull request type ENHANCEMENT
License MIT

What's in this PR?

This PR allows specifying a custom value attribute when using the <x-adminlte-input-switch> component, which defaults to 'true' when not specified. Examples:

{{-- The next component will submit 'true' when the switch is on --}}
<x-adminlte-input-switch name="example1"/>

{{-- The next component will submit '1' when the switch is on --}}
<x-adminlte-input-switch name="example1" value="1"/>

This will fix #1316

Also a new is-checked attribute (of boolean type) was added to use as an alternative of the standard checked, to simplify the usage of the component for next situation:

{{-- Instead of next code --}}
@if($isCheckboxChecked)
    <x-adminlte-input-switch name="example1" checked/>
@else
    <x-adminlte-input-switch name="example1"/>
@endif

{{-- You can now simply use --}}
<x-adminlte-input-switch name="example1" is-checked="{{ $isCheckboxChecked }}"/>

Checklist

  • I tested these changes.
  • I have linked the related issues.

@dfsmania dfsmania changed the title Allows custom value attribute on Input Switch component Improve Input Switch component Nov 7, 2024
@dfsmania dfsmania merged commit dfd6b46 into jeroennoten:master Nov 9, 2024
34 checks passed
@dfsmania dfsmania deleted the fix_issue_1316 branch November 9, 2024 16:13
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

Successfully merging this pull request may close these issues.

[BUG] x-adminlte-input-switch component: boolean error with Laravel 11
1 participant