Closed Neurergus closed 14 years ago
I'm trying to get clear what the problem is here. Am I right in thinking that you are assigning a new value to a many relationship and that having done so, the has()
method returns based on the original value and not the changed value?
Does it work as expected after save?
If that is what is going on then I agree it is not what I would expect and probably needs to be 'fixed' if it isn't already in the unstable branch.
Yes bank, you're right.
After saving, it works like expected. But in this particular case saving (at that moment) is ruled out.
Now I'm using this extended class for my needs:
class Jelly_Field_ManyToMany extends Jelly_Core_Field_ManyToMany
{
protected function _in($model, $as_array = FALSE)
{
if ( ! $model->changed($this->name))
{
return parent::_in($model, $as_array);
}
return $this->_ids($model->{$this->name});
}
}
By the way, it's the unstable branch.
Closed by 54f5fc2cddeda953dd5a2797308ebcea51aef50e. Thanks Cataphractus!
Hi,
I have a model with a ManyToMany field, activities. In the database, model 'A' has the activities 1, 2, 3.
Okay. Now suppose I do this:
I don't know if that's the desired behavior, but in my case I need to know if the model has a relationship prior to saving it, something like:
What do you think?