Comments (7)
No, I feel that providing a default value should take precedence.
from html.
The Form::model()
method is designed to allow you to pass null
s into your forms and still have them populate. The way I like to do it is like this:
{!! Form::model($model, [$routeInfo]) !!}
{!! Form::text('name', isset($model) ? null : 'Default Value', ['class' => 'form-control']) !!}
{!! Form::close() !!}
from html.
Thanks a lot for your answer !
I still do not undetstand why default value is prefered to model value ? it should be the opposite no ?
from html.
May you develop ? no troll, i just really want to understand why
from html.
Here's how I see it...
If you use Form::model()
and the provided model value takes precedence, then you have absolutely no way to override that value when using Form::text()
or any other method. Thus, you lose control over your form to some extent. In my opinion, that's not acceptable.
Either way, changing the way this works will surely break backwards compatibility.
from html.
Even if it feel strange that a 'default' value is prefered to any another one that make sense, and yes, change that will definitely break backwards compat.
Thanks again for your answer :-)
from html.
I had the same problem and finished modifying the getValueAttribute
- First if the default if $name is not provided
- Get the value that was submitted
- If not the value from special fields "_token" & "_method" & $model is set ,get the value
- Else, get the default value
public function getValueAttribute($name, $value = null)
{
if (is_null($name)) return $value;
if (! is_null($this->old($name))) {
return $this->old($name);
}
if ($name != '_token' && $name != '_method' && isset($this->model)) {
return $this->getModelValueAttribute($name);
}
if (!is_null($value)) return $value;
}
from html.
Related Issues (20)
- Site
- Active fork
- 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
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.