Best way of editing one to many table ?
Best way of editing one to many table ?
I have 2 tables with a one to many relationship, and am using editor to extract the data, using the example Multiple / Direct reference (3) here http://editor.datatables.net/manual/php/array-joins
My datatable is populating nicely, with each element of the ‘many’ array appearing as comma separated text.
I want to be able to edit the elements from the many array as discrete field entries, but not sure how I could go about it.
My editor uses the field type text by default, but this populates as a comma separated string, not an array of text fields
Ajax snippet
->join(
Join::inst( 'tblcouncilbiography', 'array' )
->join( 'CouncilMemberID', 'CouncilMemberID' )
->fields(
Field::inst( 'BiographyID' ),
Field::inst( 'BiographyDetail' )
)
)
Datatable object code
{ data: "tblcouncilbiography", render: "[, ].BiographyDetail" }
Sets out a comma separated string ;-)
Editor object code
{
label: "Bio:",
name: "tblcouncilbiography[].BiographyDetail"
}
Sets out a comma separated string.
I tried BiographyID and checkbox options in the editor, but they don’t render at all
This question has an accepted answers - jump to answer
Answers
You might be interested in the discussion in this thread which is on a similar topic.
Basically, at the moment, only the
checkbox
option from Editor's built in field types really supports the ability to do a one to many edit. If you want to be able to customise the text, you would need to create a custom plug-in that provides that ability.Allan
Thanks for the link
Custom plugin might be a little bit beyond my expertise at the mo. but I will take a look