Comments (14)
When you pass the model, you have to manually assign choices:
<?php
$this->add('fields', 'choice', [
'choices' => $this->model->fields,
...
]);
from laravel-form-builder.
No,No,,,, how to populate the values that are saved for editing
from laravel-form-builder.
I don't understand your question. When the form is submitted, you should receive selected data in Input::get('fields')
, and you handle them after.
from laravel-form-builder.
ya.. I got that but in edit form how to populate selected values in 'choice' type using model.Means,if I want to pass default value as $model->id = 1,it displays in the form but $model->fields = ['choice1'], not displaying in the form,not showing selected choice,choice1
from laravel-form-builder.
I'm not 100% sure, but i think that Laravel's form builder does not support automatically checking multiple values. You can try to put like this:
<?php
$this->add('fields', 'choice', [
'choices' => $this->model->getAllPossibleFields(),
'selected' => $this->model->fields
]);
selected
property holds the keys of all selected values, so if you have ['choice1 => 'some choice', 'choice2' => 'some other choice']
, if you want them to both be selected you put:
<?php
'selected' => ['choice1', 'choice2']
from laravel-form-builder.
Thank You,,, what I need was this 'selected' => $this->model->fields
from laravel-form-builder.
Great. It should be automatic, but i think that works only when there is one selection.
from laravel-form-builder.
it works for multiple selection too...
from laravel-form-builder.
But, how this 'selected' => $this->model->fields can be use for subforms,,Subforms generate field name as name="subFormClassName[field]"????
from laravel-form-builder.
Same way, when you initialize it, pass model and use it.
from laravel-form-builder.
if sub form attributes are the attributes of a model then how value can be populated. subFormClassName[field] is the attribute of model. $model->subFormClassName[field] = "value".
from laravel-form-builder.
I think just passing the model to the subform should work.
<?php
$this->add('sub_form', 'form', [
'class' => \FormBuilder::create('Forms/SubForm', ['model' => $this->model])
// ...
]);
from laravel-form-builder.
but passing value like this $model->subFormClassName[field] = "value" is not populating in the form
from laravel-form-builder.
yes, it's not working that way. It's not supported that way by laravel form builder class.
from laravel-form-builder.
Related Issues (20)
- v1.50 breaks field type collection HOT 5
- BUG: radio buttons chioce type returns an array HOT 5
- Feature request: Switching between classes by theme HOT 9
- Please change CHANGELOG and Releases HOT 3
- Select option for null values HOT 3
- Multiple file upload HOT 1
- Feature request: Add conditional field HOT 3
- Add Fieldset type HOT 3
- Compatibility Laravel 9 ? HOT 2
- getFieldValues() default value instead of null HOT 2
- Default placeholder for entity type(Field::ENTITY). HOT 1
- Radio button has problem HOT 2
- Using entity how we can display format with multiple columns HOT 1
- Collection of templated form HOT 2
- Error: count(): Argument #1 ($value) must be of type Countable|array, Mekongdelta\Slug\Models\Slug given HOT 5
- Validate without request HOT 10
- Invalid pattern for input
- At least one "choice" checkboxes required HOT 2
- Support for Laravel 11 HOT 4
- v1.53 - Method customLabel does not exist HOT 14
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 laravel-form-builder.