I've just coded a module in J!3.7 which should auto-generate the values of optional fields based on another required field value on save. I know that I can check values using a rule class but I had no luck overwriting the form fields there so I think it's just not possible this way. Unfortunately, I haven't found any documentation about this. I'm using a subform so things also get a bit more complicated. In my test()-function
$input->get( 'params.gmcp_content.gmcp_content0.gmcp_lng' ); // returns 8.4368239
returns the expected value which was entered manually and saved properly before to have test case. So I tried this to set the value:
$input->set( 'params.gmcp_content.' . $key . '.gmcp_lng', $lng );
But this didn't work. Neither did this:
$form->setValue( 'params.gmcp_content.' . $key . '.gmcp_lng', null, $lng );
When I dump the post array, it looks like this:
Array
(
[jform] => Array
(
[title] => Locations
[params] => Array
(
[gmcp_content] => Array
(
[gmcp_content0] => Array
(
[gmcp_contact_id] => 2
[gmcp_lat] => 49.3161506 // entered manually for testing
[gmcp_lng] => 8.4368239 // entered manually for testing
)
[gmcp_content1] => Array
(
[gmcp_contact_id] => 1
[gmcp_lat] =>
[gmcp_lng] =>
)
)
...
)
So how can I manipulate form data before the module params get saved in the database?