Comments (6)
Can you please submit the full code that is causing the error and the full HTML generated? I need to see the full line without the ......
Thanks.
from html.
Template:
{!! Field::selectmultiple('categorias[]', [], [], ['label'=>'Categorias', 'multiple ', 'id'=>'categorias', 'data-placeholder'=>'Seleccione una o más Categorias', 'class'=>'chosen-select'] )!!}
Original code produces:
<select multiple="multiple " id="categorias[]" data-placeholder="Seleccione una o mas categorias" class="form-control chosen-select" name="categorias[]"></select>
causing var c = $('#categorias');
and var c = $('#categorias[]');
to fail
Updated Code produces:
<select multiple="multiple " id="categorias" data-placeholder="Seleccione una o más Categorias" class="form-control chosen-select" name="categorias[]"></select>
allowing
var c = $('#categorias');
to work and add selected and available items via jquery/ajax calls
from html.
the name of the field (categorias[]) doesn't make sense to me, can't it be just "categorias"?
from html.
Also if you'd like to have a field like post[categories] or something like that, write it as:
{!! Field::select("post.categories") !!}
The component will then generate the appropriate name post[categories]
and the ID post_categories
from html.
If I name it just categorias, without the brackets,
the ajax call for saving data throws
Argument 1 passed to Illuminate\Database\Eloquent\Relations\BelongsToMany::formatSyncList() must be of the type array, string given, called in ...
$p->categorias()->sync($ct);
FormData (headers)
_token:zftpV77sX5ToChV7EYAnZifHGN2CkSkrBCOuGX7Y categorias:24 categorias:26 categorias:27 id:61
in the controller, where the form is submited a call to dd($request::get('categorias'))
;
returns just "27"
putting the brackets in the name, all works as expected.
Is a ManyToMany Relationship, where the edited model is submited with the selected categories its belongs. I've read in laravel docs and forums that multiselect name must include brackets to allow laravel submit this field as an array.
Also if you'd like to have a field like post[categories] or something like that, write it as >>"post.categories" the component will then generate the appropriate name post[categories] and >>the ID post_categories
Let me test it this way. The problem is than I'm filling selected and available categories via jquery/ajax/modal, and because of that, I'm can't use the laravel model/blade syntax in javascript/jquery calls. At least, don't know if is possible
from html.
You can see the same problem in core laravel form builder, back in 2013
from html.
Related Issues (20)
- compact(): Undefined variable: 'classes' in PHP 7.3
- Error in persistence of alert messages in session for Laravel 5.8 HOT 1
- Input icons
- Undefined index: theme HOT 5
- There will be support for Laravel 7? HOT 1
- Field Help HOT 1
- Hello
- Add support for PHP 8 HOT 2
- Support for Laravel 9 and future versions
- support for spatie/laravel-html
- add support for laravel 10 HOT 2
- Clase "active" Submenu dentro de un submenu HOT 2
- La clase active generada en varios items HOT 1
- Form::radios not put checked for default. HOT 1
- Blade components HOT 8
- FieldBuilder in Laravel 5.5 HOT 1
- Doesn't display errors on "nested" fields HOT 7
- [develop] Improve syntax of select from HOT 5
- compatible version with laravel 5.7 HOT 3
- [develop] Error when render a file Field with required rule
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.