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

Only works with 0 and 1, not true and false #7

Open
BenjaminBrandtner opened this issue Nov 26, 2019 · 2 comments
Open

Only works with 0 and 1, not true and false #7

BenjaminBrandtner opened this issue Nov 26, 2019 · 2 comments

Comments

@BenjaminBrandtner
Copy link

When trying to make a Toggle Field from a property that returns a php boolean, like this computed property:

public function getCompletedAttribute()
{
	return !is_null($this->completed_at);
}

this toggle switch doesn't work correctly.

It doesn't show at all on the Index Page, shows the text true on the Detail page and on forms it behaves weirdly.

@naifalshaye
Copy link
Owner

Sorry, Could you please explain the issue in more detail? thanks

@axute
Copy link

axute commented Oct 22, 2021

if the attribute on the model gives an boolean, then the toggle is not right set.
For example, the attribute gives back a boolean true, then the toggle shows "Off".

The problem is in your JS files, it is the tripple equal that only allowes integer 1 for "On" state.
field.value === 1

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

3 participants