Field labels from Database
Field labels from Database
Hi all,
I want to create a questionaire with EDITOR.
My idea: i have only 1 table:
ID| QUESTION | INFOTEXT ANSWER
1 | How are you? | Please anwer correct! | yes/no/maybe
2 | Everything ok? | Please think... | Jep / Why? / No!
...
Now I want to generate a datatable and show this items listed in the table.
now if a user ADDs a new record, I want to display a form (modal) like:
How are you? <select:>Yes/bno/maybe</select>
Please anwer correct!
Everything ok? <select:>Jep / Why? / No!</select>
Please think...
SAVE-Button
So if you can see I want to use a databse field as FIELD-LABEL and also a databse field for FIELDINFO (not a hardcoded text) like in my example:
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "./staff.php",
table: "#example",
fields: [ {
label: "How are you?",
name: "QUESTION",
}, {
...
...
$('#example').DataTable( {
dom: "Bfrtip",
ajax: "./staff.php",
columns: [
/*{ data: null, render: function ( data, type, row ) {
// Combine the first and last names into a single table field
return data.name+' '+data.vorname;
} }, */
{ data: "QUESTION" },
{ data: "INFOTEXT" },
...
Is it possible?
could you provide an example please?
thanks in advance,
jup
Answers
Hi Jup,
It is certainly something that is possible, you would need to read the information from the database to be able to build the field instances and their options. That is something that Editor doesn't provide out of the box, but it is certainly possible via the API. I'm afraid I don't have a direct example of that, but it would be worth reading over the manual for Editor if you haven't already.
Allan