[SOLVED] PHP Form Plugin | Update data OnAfterProcess

marcq

Member
Hi,

I tried several way to update one of my field without success :

PHP:
$fonction = $formModel->formData['fab_crew___fonction'];
if ($fonction === '1')
{
  $formModel->updateFormData('fab_crew___usergroup', '18', true);
} else {
    $formModel->updateFormData('fab_crew___usergroup', '17', true);
}

-----

$fonction = $formModel->formData['fab_crew___fonction'];
if ($fonction==1)
{
  $formModel->updateFormData('fab_crew___usergroup', '18');
}
if ($fonction==2)
{
    $formModel->updateFormData('fab_crew___usergroup', '17');
}

-----

$bacouni=17;
$patron=18;
$fonction = $formModel->formData['fab_crew___fonction'];
if ($fonction === '1')
{
  $formModel->updateFormData('fab_crew___usergroup', $patron);
}
if ($fonction === '2')
{
    $formModel->updateFormData('fab_crew___usergroup', $bacouni);
}

-----

$bacouni=17;
$patron=18;
$fonction = $formModel->formData['fonction'];
if ($fonction === '1')
{
  $formModel->updateFormData('usergroup', $patron);
}
if ($fonction === '2')
{
    $formModel->updateFormData('usergroup', $bacouni);
}

Would appreciate if someone could explain me what wrong.

Thank in advance.

Cheers,

Marc
 
Couple of things.

In onAfterProcess, the data has already been written out to the table. So using updateFormData() won't have any effect. You'll have to manually update the database with your new values.

Also, element names in $formModel->formData[] have been stripped of the tablename___ prefix. So use $formModel->formDataWithTableName instead.

-- hugh
 
Couple of things.

In onAfterProcess, the data has already been written out to the table. So using updateFormData() won't have any effect. You'll have to manually update the database with your new values.

Also, element names in $formModel->formData[] have been stripped of the tablename___ prefix. So use $formModel->formDataWithTableName instead.

-- hugh

Hi Hugh, thank you for your time and explanation. I figure it out and I have done it with a query which works fine now.
I just forgot to close the thread. But thank you anyway.

Cheers, Marc
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top