adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

[Bug]: Checkbox value is not sent unless touched

Open lpbonomi opened this issue 2 years ago • 1 comments

Contact Details

No response

What happened?

Checkboxes have boolean values and therefore you expect that if it not checked (the default value) it will send the value false. However, if you don't touch the field the attribute is not sent in the form and this uses the default value or throws an error in case it doesn't have one.

Screenshot 2023-09-11 at 09 28 39

Screenshot 2023-09-11 at 09 29 02

Bug prevalence

Always

AdminJS dependencies version

"@adminjs/express": "^6.0.0",
"@adminjs/prisma": "^5.0.1",
"adminjs": "^7.2.1",

What browsers do you see the problem on?

No response

Relevant log output

No response

Relevant code that's giving you issues

No response

lpbonomi avatar Sep 11 '23 12:09 lpbonomi

Still present. Any updates or workarounds on this thing? I explicitly set value to false of request param fields on before and after hooks for this matter.
For example new: { isAccessible: ({ currentAdmin }) => checkPermission(currentAdmin, Banner.ADD_PERMISSION_CODENAME, Banner.CONTENT_TYPE_ID), before: request => { if (!request?.payload?.active) { request.payload.active = false; }

mertcanbenli99 avatar Apr 18 '25 12:04 mertcanbenli99