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

Non nullable boolean UI not showing checkmark #3612

Open
gabrieletassoni opened this issue Mar 27, 2023 · 2 comments
Open

Non nullable boolean UI not showing checkmark #3612

gabrieletassoni opened this issue Mar 27, 2023 · 2 comments

Comments

@gabrieletassoni
Copy link

Describe the bug
On the Create and Edit UIs the checkboxes for non nullable boolean fields does not seem to wokr, clicking on them does not show a checkmark.

Reproduction steps
Add a non nullable field to a model (in this case User)

add_column :users, :admin, :boolean, null: false, default: false

Run rails s
Open the browser to http://localhost:3000 and navigate to User page generated by rails admin.
Click on "Create +" button.
The admin field created in the migration, does not work as expected.

Expected behavior
I expect to see the checkmark appear if I click on it.

Additional context

  • rails version: 7
  • rails_admin version: 3.1.2
  • rails_admin npm package version: not used, using sprockets
@gabrieletassoni gabrieletassoni changed the title Non nullable boolean Non nullable boolean UI not showing checkmark Mar 27, 2023
@mathieulajoienoel
Copy link

I'm having the exact same issue for rails_admin 3.1.1 and rails 7.0.4.

@mathieulajoienoel
Copy link

I fixed it on my side for now by adding
attribute :your_bool_field_here, ActiveModel::Type::Boolean.new in my model.

I think the problem is in https://github.com/railsadminteam/rails_admin/blob/master/lib/rails_admin/config/fields/types/boolean.rb function form_value. The value was '1' instead of true. Telling active_record that it was a boolean did the trick, but it was the first time I had to do that.

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