Comments (6)
I was able to get form model binding working with my belongs to many and many to many relationships by doing the following:
- Eager load the relationships in my controller.
- Extend FormBuilder and override one method:
use Illuminate\Database\Eloquent\Collection;
use Collective\Html\FormBuilder as CollectiveFormBuilder;
class FormBuilder extends CollectiveFormBuilder
{
protected function getModelValueAttribute($name)
{
$value = parent::getModelValueAttribute($name);
return ($value instanceof Collection) ? $value->modelKeys() : $value;
}
from html.
@robgridley thanks for sharing your solution! :) 👍
I've extended the Collective as described here: https://laracasts.com/discuss/channels/general-discussion/best-way-to-overwrite-option-method-from-laravel-5-formbuilder-class
from html.
👍 thanks for the solution @robgridley , I expect the same behavior as mentioned by @agentphoenix
from html.
@adamgoose will this fix (or a similar fix) be merged into the repository or is the expectation that individuals will need to extend the getModelValueAttribute
method ourselves to get form model binding working?
from html.
Yes, it was fixed in #45
from html.
Awesome! Thanks for fixing this. Huge help! 👍
from html.
Related Issues (20)
- Html
- <!DOCTYPE html> <html> <head> <title>Parcel Sandbox</title> <meta charset="UTF-8" /> </head> <body> <canvas id="canvas"></canvas> <script src="./index.js" type="module"></script> </body> </html>
- Html
- My html project
- Html
- Sf
- Html
- Laravel 11 Compatible Fork Is Here [INFO] HOT 5
- Flexiwork
- Teste1
- Nelzy Webpage Simple
- Html
- G
- Portfolio
- Dg
- Carta
- Project
- Laravel 11 php 8.2 not working. HOT 1
- Web page
- Tes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html.