dimanche 20 novembre 2016

Error Model setting relationships with Octobercms

I'm testing Octobercms and I'm trying to setup a relationship between two tables ('textos' and 'tipos'), but I'm getting the next error when I try to edit one of my 'textos':

Model 'Javier\Textos\Models\Texto' does not contain a definition for 'tipo'.

What I would like to do is to choose a 'tipo' when I'm creating a 'texto'...

This is my Tipo (model) relationship:

public $belongsToMany = [
    'textos' =>[ 
        'Javier\Models\Texto',
        'table' => 'javier_textos_textos_tipos',
        'order' => 'texto_id'
    ],
];

This is my Texto (model) relationship:

public $belongsToMany = [
    'tipos' =>[ 
        'Javier\Models\Tipo',
        'table' => 'javier_textos_textos_tipos',
        'order' => 'tipo_id'
    ],
];

I'm using a pivot table to manage that relation with just two columns: tipo_id and texto_id

In my models\texto\fields.yaml you can see that:

fields:

tipo:
    label: 'javier.textos::lang.textos.tipo-texto'
    oc.commentPosition: ''
    nameFrom: tipo
    descriptionFrom: description
    span: auto
    type: relation



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire