I need to loop through a list of fields in a custom validator to compare the value against a value already stored in the database.
My code here:
$healthUser = PersonTable::getInstance->getHealthUser(trim($values['nhi']));
if ($healthUser->getNHI() == trim($values['nhi']) &&
$healthUser->getName() != trim($values['name'])){
//Also loop through all fields and show differences
foreach (array('suite','hnr_street','suburb','city','postcode','postal_address')
as $field){
if ($value[$field] != $healthUser->getFieldName()){
//How do I get the field name from $field?--^^^^^^^^^^
$errorSchemaLocal->addError(new sfValidatorError($this,
'fieldIsDifferent', $healthUser->getFieldName()),
$field);
}
}
SO basically i need to create the getter function from the field name in $field.
Any idea how to do this?