I'm using fieldname_validate() on the data within a grid widget, which works like a charm.
I need to pull the id field, so: $record->val('{record_id}'), except here it's returning null. After some further testing, $record->val(ANYTHING) is returning null, but only within the fieldname_validate function. I did a print_r($record) to see if maybe for some reason it was the relationship's record, but I was able to find my correct [{record_id}] => {record_id}, and other form data within it. So, I'm not sure what's going on / why I'm not getting anything back.
Initially, I was using the beforeSave trigger, which worked just fine, but I ended up needing to be able to check against values that were being entered (before changing to fieldname_validate, I actually tried $_POST w/ beforeSave which I've done before to get the user entered values, but that didn't work. I am assuming that relationships are saved differently... I think I read via AJAX instead of PHP).
I went as far as to parse out the ID field from the generated [__id__] tag in $values. Besides seeming incredibly hackish, this only works if there is already relationship data saved.
Everything else is working as expected, but just in case I'm doing something dumb (which I will admit is quite possible)..
The table is called "call_slips", and "call_id" is the primary index.
My fields.ini file shows:
- Code: Select all
[inventory]
transient=1
widget:type=grid
relationship=call_slip_inventory
widget:columns="inventory_id, quantity"
relationships.ini:
- Code: Select all
[call_slip_inventory]
__sql__ = "SELECT * FROM call_slip_inventory WHERE call_id='$call_id'"
delegate class file - I cut everything else out of inventory__validate except to throw an error to display the id field
- Code: Select all
function inventory__validate(&$record, $value, &$params){
$params['message'] = 'Record ID: '.$record->val('call_id');
return 0;
}
And I'm getting:
Errors
Some errors occurred while processing this form:
Record ID:
as a result.
Thoughts?