econveyors
Member
Here's my situation and the functionality I'm looking to accomplish:
- I have a form that uses the upsert plugin to copy the form data to a second table.
- For one specific field, I only want it to overwrite the second table's data if the form field contains a value.
- If the form field is empty, I want the data that's already in the second table's field to remain untouched.
I've tried using just the placeholder as well as several versions of code to check if the form field contains data, but what continues to happen is this:
- When the form field contains a value, the field in the second table is successfully updated with the form field's value.
- When the form field is empty, the field in the second table is updated, but it's blank... I'm assuming because the form field was left blank.
Here's what I've tried. This code is being inserted into the "Value" field in the Upsert plugin and evaluated as PHP (obviously except for when I tried just the placeholder.)
Placeholder
Example 1
Example 2
Example 3
Example 4
This feels like it should be pretty simple, but for some reason I can't figure out what I'm missing.
Thanks!
- I have a form that uses the upsert plugin to copy the form data to a second table.
- For one specific field, I only want it to overwrite the second table's data if the form field contains a value.
- If the form field is empty, I want the data that's already in the second table's field to remain untouched.
I've tried using just the placeholder as well as several versions of code to check if the form field contains data, but what continues to happen is this:
- When the form field contains a value, the field in the second table is successfully updated with the form field's value.
- When the form field is empty, the field in the second table is updated, but it's blank... I'm assuming because the form field was left blank.
Here's what I've tried. This code is being inserted into the "Value" field in the Upsert plugin and evaluated as PHP (obviously except for when I tried just the placeholder.)
Placeholder
Code:
{tablename___elementname}
Example 1
Code:
$formField = $formModel->fullFormData['tablename___elementname'];
if(!empty($formField)):
return $formField;
endif;
Example 2
Code:
$formField = $formModel->fullFormData['tablename___elementname'];
if(isset($formField)):
return $formField;
endif;
Example 3
Code:
$formField = $formModel->fullFormData['tablename___elementname'];
if(isset($formField) && !empty($formField)):
return $formField;
endif;
Example 4
Code:
$formField = $formModel->fullFormData['tablename___elementname'];
if($formField != ''):
return $formField;
endif;
This feels like it should be pretty simple, but for some reason I can't figure out what I'm missing.
Thanks!