fix checkboxes shown as checked when they're not with mysql
The issue occurs because boolean/tinyint values are retrieved from mysql as strings, and in php/js all non-empty strings are cast as boolean true. Current PDO mysql driver doesn't support `PDO::ATTR_STRINGIFY_FETCHES = false`, and if I disable prepare-emulation so it uses the native MySQL driver instead which supposedly does support it, prepare statements no longer play nice with named parameters. Every remaining clean solution that comes to mind that can cover all cases, just for MySQL, adds an annoying amount of additional code / overhead. As long as the `App.FormFields.checkbox_tag()` JS function is the only one suffering from the lack of conversion, I'll go with easy ugly over here.
This commit is contained in:
parent
2f2642bbd4
commit
27b676b7b2
|
@ -43,8 +43,9 @@ const App = {
|
|||
return this.button_tag(value, "", {...{onclick: "App.dialogOf(this).hide()"}, ...attributes});
|
||||
},
|
||||
checkbox_tag: function(name, checked = false, value = "", attributes = {}, id = "") {
|
||||
// checked !== '0' prevents mysql "boolean" false to be implicitly cast as true
|
||||
return `<input dojoType="dijit.form.CheckBox" type="checkbox" name="${App.escapeHtml(name)}"
|
||||
${checked ? "checked" : ""}
|
||||
${checked !== '0' && checked ? "checked" : ""}
|
||||
${value ? `value="${App.escapeHtml(value)}"` : ""}
|
||||
${this.attributes_to_string(attributes)} id="${App.escapeHtml(id)}">`
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue