This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

mrd
mrd

So i have issue when using datatable type fields on a Relation Table.

I have two table named a_table and b_table.

on a_table i set the fields.yaml : b_table: tab: b_tab_name type: partial path: field_b_table

where on controllers/a/_field_b_table.html, i call the relation render : <?= $this->relationRender('b_table') ?>

which on a model, i have this relation : public $hasMany = [ 'b_table' => ['Models\BTable', 'table' => 'b_table', 'order' => 'title'], ];

on the b_table, i set the fields.yaml : json_field: tab: tab_name label: Label type: datatable columns: title: title: Title value: title: Value

So from the UI, everythings actually working properly, the datatable show up, and i can fill in the data dynamically on the fly. But the issue is on saving process, the b_table.json_field is only saving empty [] data, not saving the json value i filled in.

This only happen on a relation table form, if i set the datatable directly on a_table for example, it saved properly. Not sure if there's other thing i need to setup here for relation table, i can't find any documentation either.

Any help would be appreciated. Thx.

dazmiller8556
dazmiller8556

Have you added the field in your model to the $jsonable array?

mrd
mrd

yes i did, if not the datatable will throw error, as i said above, there's no error, only on the saving process it didn't store the json value, just empty value. And this is not happening if it's on the parent table.

chris10207
chris10207

usually, this is happening when the field is not declared in the protected $fillable array

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.