0

I have implement relationController in the model that i build..

child model listed inside parent model form.. and it works perfectly but it doesnt meet my requirement..

the things is

the child model listed is only the one related to parent model id that is defined in the child model..

so child model record only belongsTo one parent model record, so when i create new record, the child model doesnt display any record..

i need all child model records display in all parent model records, so
even when we create new record, all the child model is also listed..

i tried to use belongsToMany relationship, but it does the same way as belongsTo relationship.

is there a way for this?

Isral Bustami
  • 137
  • 13
  • can you share schema of models, briefly so it will be easy to understand, as well "child model listed inside parent model form" <- why you need this means just information purpose or you use them as any relation ? – Hardik Satasiya Mar 17 '18 at 11:15
  • Hi sir.. i have solved this by reviewing october cms documentation.. by using belongs to many with pivot table and activate it by add button as an additional of create and delete button.. – Isral Bustami Mar 18 '18 at 08:01
  • Sir.. earlier you gave me solution about displaying repeater widget form without user action.. now that form is in inside the child model.. and since the child model doesnt have controller where should i put the code you gave me.. https://stackoverflow.com/q/48697596/2184900 – Isral Bustami Mar 18 '18 at 08:06
  • 1
    i guess you can add that code on main controller `if(is_null($form->model->id)) {` like this you add more condition based on model there and write your code there `$form->model instanecof \some\childmodel` as main controller will be handler for all – Hardik Satasiya Mar 18 '18 at 09:23
  • Sir.. tried but how we define iteration variable to get `maxItems` from child model – Isral Bustami Mar 19 '18 at 06:36
  • can you confirm me that when you open main form argument `public function formExtendFieldsBefore($form)` will be for `main model` and when you again open child from `$form` is of which model , means its of `main model` or `child model` – Hardik Satasiya Mar 20 '18 at 06:27
  • Yes.. the function for main model and child open from main model.. in the iteration function i replace `$form->model->fieldname = $emptyfield; ` into `$emptyfield = $form->model instanceof childmodel` – Isral Bustami Mar 20 '18 at 06:35

0 Answers0