Reputation: 77
i'm trying to create back-end Relationships (be more specific one to one type) with partly success, if I'm inserting information throw php-my-admin information show up, but when i try to enter information throw OctoberCMS back-end form, then information is recorded just in first major table, but not in second.
So I have two tables (first one, major)randman_random_rooms with fields [id, view, places, cleaned] and randman_random_room_description with fields [id, description, room2_id] in my room2s.php model i have
public $hasOne = [
'roomdescription' => [
'\Randman\Random\Models\RoomDescription',
'key' => 'rooms2_id',
'otherKey' => 'id'
],
];
and in model rooms2 columns.yaml
roomdescription:
label: 'description'
relation: roomdescription
select: decription
type: text
and finally in my rooms2 fields.yaml
roomdescription:
label: description
span: auto
oc.commentPosition: ''
type: number
so what am i missing here?
Upvotes: 0
Views: 101
Reputation: 126
Please take a look for roomdescription type: "number". It is relation not a number. You probably should change roomdescription type to: "relation" and use Relation Widget. Or if you want put exact id number use proper id field name. For further debug you can use trace_log() function that will put sql queries to your log file.
Upvotes: 1