Adding a grid field type to my custom module
Created 7 years ago by william

I want to add a grid field to my module. I have a migration that looks as follows:

use Anomaly\Streams\Platform\Database\Migration\Migration;

class ProjectModuleEventsCreateContentField extends Migration
{

    /**
     * @var array
     */
    protected $stream = [
        'slug' => 'events',
    ];

    /**
     * @var array
     */
    protected $assignments = [
        'content' => [
            'translatable' => true,
        ],
    ];
    /**
     * The addon fields.
     *
     * @var array
     */
    protected $fields = [
        "content" => [
            "type"   => "anomaly.field_type.grid",
            "config" => [
                "related" => ['\Anomaly\Streams\Platform\Model\Grid\GridCalloutEntryModel'],
                "max"     => null,
                "min"     => null,
                "add_row" => "anomaly.field_type.grid::button.add_row",
            ],
        ],
    ];

}

But i am getting an error:

Object of class ..GridFieldType\Grid\GridRelation could not be converted to string

Leaving out related field or as an empty array doesn't work either. Am i missing what the related field should be?

william  —  7 years ago

So i changed content , to contents... And then it all works fine. Very strange my friends...