Closed gmhenderson closed 6 years ago
+1 (just figured out the same problem)
my quick and dirty fix:
if (method_exists($this->model, 'form' . Str::studly($key) . 'Attribute')) {
$value = $this->model->{$key};
return $this->model->{'form' . Str::studly($key) . 'Attribute'}($value);
}
+1
Not sure about this one, because right now the formMyAttribute
is working correctly if you use the FormAccessible
trait: is this issue relevant to an outdated version or is there more to it? Any ideas @tshafer @adamgoose ?
The documentation regarding form model accessors (https://laravelcollective.com/docs/5.2/html#form-model-accessors) does not match the implementation in the code. Currently, the
getModelValueAttribute()
method inFormBuilder.php
, looks for a model method calledgetFormValue()
whereas the documentation says to create a model method likeformMyAttribute()
. Does the documentation need to be updated to match the code or vice versa?For what it's worth, I think I like the format suggested by the docs better than what the code currently implements. Having a single
getFormValue()
method requires a bunch of conditionals to figure out which attribute to return; using multiple methods seems cleaner. Then again, once could implement a number of protected methods called bygetFormValue()
...I can submit a PR with either fix. And thanks for the work you've put into this package, it's been a pleasure to work with.