Hi,
I am developing a plugin in which a Course hasMany Schedule . I want to be able to add/edit/delete schedules inside the course edit screen in the backend. I have followed the guidelines provided in http://octobercms.com/docs/backend/relations
In Course Model:
public $hasMany = [
'schedules' => ['Echo1\Training\Models\Schedule', 'table' => 'echo1_training_schedules', 'order' => 'id']
];
In Courses controller I have:
public $implement = [
'Backend.Behaviors.FormController',
'Backend.Behaviors.ListController',
'Backend.Behaviors.RelationController',
];
public $relationConfig = 'config_relation.yaml';
config_relation.yaml file for Courses controller:
schedules:
label: Course Schedule
view:
list: ~/plugins/echo1/training/models/schedule/columns.yaml
toolbarButtons: create|delete
manage:
form: ~/plugins/echo1/training/models/schedule/fields.yaml
recordsPerPage: 10
I have <?= $this->relationRender('schedules') ?> In course update.htm
When I update a Course I can see table for list of Schedules. When I click Add Schedule a popup form appears with timings input text field but when I save it throws me an error: Mass assignment failed for Model attribute 'Timings'
In the schedules table I have id, timings, course_id and timestamps. I have no validation rules inside Schedule Model.
Please help me if you have any idea how to resolve this error.
Thanks a lot.