Suddenly, a solution was found. I did not understand what was the matter. If you send a request like this (below), then everything is ok - the data comes to the server as an array.
jQuery('#peoples_form').submit(function (e) { e.preventDefault(); var peopleData=$(this).serialize(); $.ajax({ type: "POST", url: '/site/add-new-people', async: async, timeout: 20000, dataType: datatype, data: peopleData, success: function(result){console.log(result);}, error: function(err){console.log(err);} }); });
But if you send it like this (Ajax is rendered as a function)
jQuery('#peoples_form').submit(function (e) { e.preventDefault(); var peopleData=$(this).serialize(); aj('/site/add-new-people', {'peopleData': peopleData}); }); function aj(url1, data, async='false', datatype='html') { $.ajax({ type: "POST", url: url1, async: async, timeout: 20000, dataType: datatype, data: data, success: function(result){console.log(result);}, error: function(err){console.log(err);} }); }
That data arrives not as an array, but as a string of the form
_csrf=vk2P3oAnKy855oOydhIt_xcX6ZFuHp1t3AJkGg9eFTlv3-2I0kuToH7bBm3V32uvZFnLhu8-UCkp99pmEv7qug%3D%3D&People%5Bsurname%5D=111&People%5Bfirst_name%5D=&People%5Bmiddle_name%5D=&People%5Bbirth_year%5D=121&People%5Bissue_date%5D=&People%5Bissued_by%5D=&People%5Bpassport_number%5D=111&People%5Bregistration%5D=&People%5Bgender%5D=111&People%5Bclient_note%5D=
Which I still could not cram into the model. The problem seems to be solved. But the reason is not clear to me. It can be seen, this is due to the fact that in the way I passed the data to the function as json.
There is only one oddity left - if you reload the page and submit the form, for some reason, ajax works twice. After that (before rebooting) as it should be - once. It was decided - it’s necessary to hang js not on the submit event, but on('beforeSubmit', 'form#peoples_form', function (e) and add return false at the end on('beforeSubmit', 'form#peoples_form', function (e) ;