I'm using a frontend JForm to manipulate some data. The html form is correct, but when it is sent back to the model save function I don't receive all data.
This is the data that save
receives through $data
parameter:
Array
(
[created] => XXXXXXXXXXXXXXXXX
[updated] => XXXXXXXXXXXXXXXXX
[wasteId] => X
[price] => XXXX
[pricenight] => XXX
[pricefreeday] => XXXX
[pricefreedaynight] => XXXX
[tags] =>
)
But when I use
$formData = new JRegistry($this->input->get('jform', '', 'array'));
or when I got the data as the JControllerForm save method does
$formData = new JRegistry($this->input->post->get('jform', array(), 'array'));
I've got
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[wasteId] => X
[price] => XXXX
[pricenight] => XXX
[pricefreeday] => XXXX
[pricefreedaynight] => XXXX
[contractId] => Array
(
[0] => XX
[1] => XX
)
[created] => XXXXXXXXXXXXXXXXX
[updated] => XXXXXXXXXXXXXXXXX
[id] => XX
)
)
So fields id
and contractId
are missing in the $data
parameter.
Any idea of what should I do to have contractId
and id on the $data
parameter of the model save
function?
By the way, the model I'm using is derived from JModelAdmin and the controller is derived from JControllerForm. The controller has no overriden functions which may affect the way it collects data from the form.
EDIT
More clues: inspecting the JControllerForm::save
more in detail I've seen that $data
has the id
component with the correct value but it gets overwritten with an empty value around line 637 because of this:
$recordId = $this->input->getInt($urlVar); // around line 634 of JControllerForm
sets $recordId
to an empty value, in spite of $urlVar
value is "id". Then later, around line 637 of JControllerForm $data["id"] is changed:
$data[$key] = $recordId
$key
value is "id" and $recordId
is empty.
Thanks.