Skip to content

Can't add ManyToMany relations on a new Model #94

@ccazette

Description

@ccazette

... and probably HasMany relations neither looking at the code...

These lines (Core_Model line 353 - don't know why they have been added from the original Jelly) :

        // Set an empty value to NULL for deleting relationships
        if (($field instanceof Jelly_Field_HasMany OR $field instanceof Jelly_Field_ManyToMany) AND empty($value))
        {
            $value = NULL;
        }

Actually set a the manytomany field to NULL, so the field is reported as 'changed' with a NULL value. If you then try to add a new relation, then this line (942) in the _change() method will trigger an exception as it will run array_merge with a NULL parameter :

    if ($add)
    {
        $changes = array_unique(array_merge($current, $changes));
    }

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions