I'm trying to use the hook civicrm_buildForm
to modify the contribution value based on specific logic.
I know I can use setDefaults()
but I don't know how to get the field ID.
For this contribution form, I'm using a Price set.
Update
I tried this, but it didn't work:
if (isset($form->_priceSet['fields'])) {
foreach ($form->_priceSet['fields'] as &$field) {
if ($field['name'] == 'amount') {
foreach ($field['options'] as &$option) {
if ($option['label'] == 'Amount') {
$option['amount'] = 50;
}
}
}
}
}