Requested unknown parameter 'xx' for row error

Requested unknown parameter 'xx' for row error

AVHtechAVHtech Posts: 7Questions: 3Answers: 1

I've been running into the "Requested unknown parameter " response error after attempting to update a record via the editor. After many hours of reading, I believe I understand the problem and wy it is happening but I don't know how to fix it.

My ajax data query that populates the Datatable contains data from multiple tables and is included in a 'jobs' object in the JSON returned:
Query:

SELECT Jobs.id, Jobs.Company_Id AS Company_Id, Jobs.Location AS Location_Id, Companies.Name AS Customer_Name, Locations.Name AS Location_Name FROM Jobs LEFT JOIN Companies on Jobs.Company_Id = Companies.id

JSON:

{"data":[{"Jobs":{"id":"2","Company_Id"::"1","Location_Id":"1","Customer_Name":"XYZ","Location_Name ":"ABC"}}]}

My DataTable field names match the data query fields so that is fine and the data populates correctly:

columns: [
{ data: 'Jobs.id'},
{ data: 'Jobs.Customer_Name'},
{ data: 'Jobs.Company_Id' },
{ data: 'Jobs.Location_Name' },
{ data: 'Jobs.Location_Id' }]

My editor field names match the DataTable fields that belong to the table I am updating (Jobs) as the other fields related to the Companies and Locations tables are not being updated.

fields: [
{label: 'Job Number', name: 'Jobs.id', type: 'readonly'},
{label: 'Customer', name: 'Jobs.Company_Id'},
{label: 'Location', name: 'Jobs.Location_Id'}]

The editor form shows up correctly and displays the correct data. When I make a change and submit the data it updates the table correctly but the edit form freezes up and the error is displayed in the console. The problem comes in with the response JSON that is sent back to the client. The response does not include parameters for Customer_Name and Location_Name as these fields were not part of the POST payload from the editor. The error is displayed as the DataTable is looking for these two values. The way I see it I have to submit these values as part of the update but they are not in the Jobs table so I can't see how to include them in the following statement:

$editor = Editor::inst($dbDataTables, 'Jobs') ->fields(Field::inst('Jobs.Company_Id'),Field::inst('Jobs.Location','Jobs.Location_Id'));

echo json_encode($editor->process($_POST)->data());     

Do I need to POST these fields that belong to another table that is not being updated just so they can be returned to the client or do I somehow manipulate the return data to add these values back in?

I hope this makes sense. I constructed sample code here to explain the problem

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited June 2023

    I see you're using Editor in your example, but our accounts aren't showing that you have a license or initiated a trial. Is the license registered to another email address? Please can let us know so we can update our records and provide support.

    Thanks,

    Colin

  • AVHtechAVHtech Posts: 7Questions: 3Answers: 1
    Answer ✓

    I found the issue. I had serverSide set to false. I changed it to true and now it is working correctly.

Sign In or Register to comment.