kristijanhusak/laravel-form-builder
Embedded child form models being converted to arrays
Open
#184 opened on Nov 18, 2015
help wanted
Repository metrics
- Stars
- (1,715 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
I am trying to add a child form that uses a related model.
$this
->add('name', 'text')
->add('directories', 'form', [
'class' => 'DirectoriesForm',
'formOptions' => [
'model' => $this->model ? $this->model->directories : null,
],
])
In \Kris\LaravelFormBuilder\Form::setupNamedModel it is converting the child model to an array, so I can't call any methods on it. Why is this? It prevents me from calling any model methods in the child form. As far as I know, I'm not even using a named form, unless this happens automatically for child forms. If I get rid of the dotName stuff and just set
$this->model = [
$this->getName() => $this->getModel()
];
it seems to work fine. Am I doing something wrong here? Thanks.