Using format_input_fun with custom input fields
Using format_input_fun with custom input fields
maven
Posts: 2Questions: 0Answers: 0
I needed to change a standard text input field to a set of checkboxes, to allow for multiple-choice selection in a data column. I added the reference to [code]format_input_fun => array(&$this, 'formatCategory')[/code] in the $tableColumns array, and created the function (and required javascript to make it operate). As part of the function, I created a hidden input field to hold the actual data, and 6 checkboxes without id's for the various options. The Javascript code fired when a checkbox was clicked to update the hidden field with the list of options selected.
The problem occurred when saving, because the updateRow, updateMultRows and addRow functions loop through every field in the record, whether or not it has an id, and attempt to add it to the update query.
To take care of this, I changed this line in the three functions:
[code]
info[inputId] = $(inputId).value;
[/code]
to:
[code]
//(ignore inputs without an id)
if (inputId) {
info[inputId] = $(inputId).value;
}
[/code]
Hopefully that helps somebody else.
-Mike Ethetton
The problem occurred when saving, because the updateRow, updateMultRows and addRow functions loop through every field in the record, whether or not it has an id, and attempt to add it to the update query.
To take care of this, I changed this line in the three functions:
[code]
info[inputId] = $(inputId).value;
[/code]
to:
[code]
//(ignore inputs without an id)
if (inputId) {
info[inputId] = $(inputId).value;
}
[/code]
Hopefully that helps somebody else.
-Mike Ethetton
This discussion has been closed.