[Custom Module] EntryModel getField() returns null
Created 6 years ago by damian_nz

Hi there, I am trying to add the following migration to an existing stream.

    protected $fields = [
        'group'   => [
            'type'   => 'anomaly.field_type.relationship',
            'config' => [
                'column_type' => 'integer',
                'related'     => 'MyNamespace\MyModule\Filter\FilterModel',
                'handler'     => 'MyNamespace\MyModule\Filter\Handler\PopulateFilterOptions@customGrouping'
            ]
        ],
    ];

When I try to compile or refresh the streams after running the migration I get the following error.

Call to a member function getSlug() on null
() at /vagrant/cms/vendor/anomaly/streams-platform/src/Assignment/AssignmentModel.php:127

This is the getFieldSlug function. Is there something missing from my config for the new field?

damian_nz  —  6 years ago Best Answer

I figured it out Ryan (not sure what that emoji would look like)

So in my handler I was type hinting the wrong field type. The error message sent me looking in the wrong place 😄

Thank you for your time

ryanthompson  —  6 years ago

Did you assign it? The field will really only put it into the field pool for the namespace.

damian_nz  —  6 years ago

Yeah I have

    protected $assignments = [
        'group'
    ];

in the migration also

damian_nz  —  6 years ago Best Answer

I figured it out Ryan (not sure what that emoji would look like)

So in my handler I was type hinting the wrong field type. The error message sent me looking in the wrong place 😄

Thank you for your time

ryanthompson  —  6 years ago

Lol all good! I have emojis staged locally by the way 😄 along with a ton of other goodies