livewire-select icon indicating copy to clipboard operation
livewire-select copied to clipboard

Add support for `multiple` attribute

Open bfiessinger opened this issue 3 years ago • 2 comments

reopened #34 on new branch. This PR adds the ability to select multiple values.

By adding the multiple attribute on the component the select input turns into a multi-select dropdown.

<livewire:car-model-select
    name="car_model_ids[]"
    placeholder="Choose a Car Model"
    :multiple="true"
/>

Example: multiselect

To include the required assets I've also made some small changes on the blade directives.

  • Updated directive livewireSelectScripts
  • Added directive livewireSelectStyles

Both directives now support options where you can set which assets should be loaded.

...
    @livewireSelectStyles 
    <!-- 
         loads all styles defined in Asantibanez\LivewireSelect\LivewireSelect->css.
         omit this directive completely if Livewire::styles() and tailwindcss is already included on the page
     -->
</head>
<body>
    ...
 
    @livewireSelectScripts(alpine, livewire-select-multiple) 
    <!-- loads only alpinejs, livewire-select-multiple and the default required livewire-select-->
</body>
</html>

also closes #22 by 25f5147

bfiessinger avatar Aug 27 '21 18:08 bfiessinger

According to #39 where the initial value is nulled for dependant selects I already built something to make it work on this multiple input too. Please merge #39 and #37 first so I can push the next step.

bfiessinger avatar Aug 28 '21 18:08 bfiessinger

@asantibanez is this something you plan to merge ? Just to know if I wait for it or if I implement another solution in the app I'm currently working on :)

Thank a lot

mydnic avatar Sep 22 '21 14:09 mydnic