I am new to Laravel and I am trying to add an input from where it lets the user add multiple languages and saves them as a list.
for example, the user can enter English, Spanish, Arabic and saves each input as a list to the same field Something similar to the tags field in Stack Overflow when adding tags enter image description here
CodePudding user response:
If you are trying to reach tags functionality There's Spatie Laravel library really good
check it out https://github.com/spatie/laravel-tags
CodePudding user response:
if you want to send multiple options , you can use select 2 js plugin : [https://select2.org/getting-started/basic-usage][1]
use script src in your template , and then :
<script>
$('.multi-select').select2();
</script>
and then , in your html code do something like this :
<select class='multi-select form-control' multiple=''
data-placeholder='Enter Tags' aria-hidden='true' name='tags[]'>
<option value="1">tag 1</option>
<option value="2">tag 2</option>
<option value="3">tag 3</option>
</select>
notice that the key is your select element's name should be an array ;
hope that would work .