Editor select field with attr example
Editor select field with attr example
How can i recognise the correct select field with multiple tables/select fields on one page?
If i use a select field in an inline editor table (inline editing), eg:
HTML:
<tr id="jobgroup-1_joID-3">...<td class="jobgroupName editable">Linie 1</td></tr>
JavaScript:
fields: [{
name: "jobgroupName",
type: "select",
placeholder: "Choose:",
options: { "Linie 2":"2", "Linie 3":"3", "Linie 4":"4","Linie 5":"5" }
},{ ...
The resulting AJAX post looks like:
array(
['action'] => 'edit'
['data'] => array(
['jobgroup-1_jobId-3'] => array(
['jobgroupName'] => 2
)
)
)
So im able to recognise the correct action with the string 'jobgroup-1_jobId-3'.
But with an "new" bubble in an other table, i got:
array(
['action'] => 'create'
['data'] => array(
[0] => array(
['employee'] => 2
['mo'] => 8
['tu'] => 8
['we'] => 8
['th'] => 8
['fr'] => 8
['sa'] => 0
)
)
)
But i want to get it like this:
array(
['action'] => 'create'
['data'] => array(
['jobgroup-1_newEmployee'] => array(
['employee'] => 2
['mo'] => 8
['tu'] => 8
['we'] => 8
['th'] => 8
['fr'] => 8
['sa'] => 0
)
)
)
attr: { multiple: true } works, but something like
attr: { "id":"jobgroup-1_newEmployee" } does not work for me.
This question has an accepted answers - jump to answer
Answers
The
0in the submitted data for the create indicates that it is a single new row. Editor actually can submit multiple new rows at the same time for creation (create()) which is why that index exists at all.Are you able to modify the server to expect the data that Editor is sending?
Allan
Ok, i understand. But how can i distinguish the different selects on one page? I need a unique attribute for each select.
Yes, of course.
Editor should submit a different value for each
selectfield.Could you show me the Javascript for your Editor initialisation please?
Allan
Or can i change ['action'] => 'create' into something like ['action'] => 'createNewEmployee'?
You only have a single field called
employee. I'm not sure wherejobgroup-1_newEmployeeis coming from?You can use the
ajax.dataoption to modify the data being submitting to the server, for example changing the value of theactionproperty.Allan
It (jobgroup-1_newEmployee) should have been there (my wish).
Ok, this works fine, eg:
Result:
Thank you so much.
Last remark: Now i can override the action value, too:
Result:
This is very good. Thanks and bye.
Fantastic. Good to hear you've got it working as you need to now!
Allan