[eluser]cberk[/eluser]
I switched to DMZ from the original Datamapper and was pleased with how seamless the transition was. However, I am getting an error now that I wasn't getting before, and haven't been able to figure out why.
I have two models, and am using the related_min_size validation rule on one of them. Here are the relevant excerpts (MyDataMapper is just an extension class of DataMapper):
Code:
class State extends MyDataMapper {
var $has_many = array("metro");
Code:
class Metro extends MyDataMapper {
var $table = 'metros';
var $has_many = array("state");
var $validation = array(
array(
'field' => 'state',
'label' => 'State',
'rules' => array('min_size' => 1) // A metro must be associated with at least one state
)
);
When I try to update and save an existing metro (it already has a relationship to a state), I get the following error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Object of class State could not be converted to int
/**
* Min Size (pre-process)
*
* Checks if the value of a property is at least the minimum size.
*
* @access private
* @param string
* @param integer
* @return bool
*/
function _min_size($field, $size)
{
return ($this->{$field} < $size) ? FALSE : TRUE;
}
It looks like DMZ is calling the normal 'min_size' validation rule rather than the 'related_min_size' function. Is this a problem with how I'm declaring my models, or is a bug?