protected function defineValidationFields($PostedFields, $Insert = false)
{
$Result = array();
// Start with the fields that have been explicitly defined by `ApplyRule`.
foreach ($this->_FieldRules as $Field => $Rules) {
$Result[$Field] = val($Field, $PostedFields, null);
}
// Add all of the fields from the schema.
foreach ($this->getSchemaRules() as $Field => $Rules) {
$FieldInfo = $this->_Schema[$Field];
if (!array_key_exists($Field, $PostedFields)) {
$Required = in_array('Required', $Rules);
// Don't enforce fields that aren't required or required fields during a sparse update.
if (!$Required || !$Insert) {
continue;
}
// Fields with a non-null default can be left out.
if (val('Default', $FieldInfo, null) !== null || val('AutoIncrement', $FieldInfo)) {
continue;
}
}
$Result[$Field] = val($Field, $PostedFields, null);
}
return $Result;
}