Bug report: inline standalone editor with relations issue
Bug report: inline standalone editor with relations issue
I found it doesn't work properly for relation fields. At the same time it works perfectly for non-standalone editor with 100% same configuration.
Editor Declaration:
[
'name' => 'personality_attributes',
'data' => 'personality_attributes[].personality_attribute_id',
'label' => 'Personality attributes',
'type' => "select2",
'options' => [["value" => "test", "label" => "test label"], ["value" => "test2", "label" => "test label2"]],
"opts" => [
"placeholder" => "Personality attributes",
"allowClear" => true,
"multiple" => true
],
],
Column Declaration:
[
'data' => 'personality_attributes',
'title' => 'Personality Attributes',
'orderable' => false,
'searchable' => false,
'render' => "[, ].personality_description"
],
Data response:
{"personality_attributes": [{"personality_attribute_id": 1}],[{"personality_attribute_id": 2}],[{"personality_attribute_id": 3}]}
Inline element:
<dd data-editor-field="personality_attributes" data-table-field="personality_attributes"></dd>
Editor 1.7.4
Datatables 1.10.19
It seems problem related to possibility to link data with Editor column declaration function
function __html_el(identifier, name) {
var context = __html_id(identifier);
return $('[data-editor-field="' + name + '"]', context);
}
name field in __html_el will be "personality_attributes[].personality_attribute_id" instead of "personality_attributes" so it can't locate proper field
Following dirty fix can make it work
function __html_el(identifier, name) {
var context = __html_id(identifier);
if(name.indexOf('[') !== -1)
name = name.substring(0,name.indexOf('['));
if(name.indexOf('.') !== -1)
name = name.substring(0,name.indexOf('.'));
return $('[data-editor-field="' + name + '"]', context);
}
Answers
Hi,
Thanks for posting this. Are you able to link me to your page so I can check it out please? Feel free to send me a PM if you prefer not to make it public (click my forum name above and then Send message).
Allan