multimple select2 with laravel vue js not working - laravel

i want to make dynamic form .so for that i tried foreach loop .everything going fine without select options. For making classname or id name unique i want place a index value but cant not place index value.take a look below:
<div class="form-group m-form__group row " v-for="(pack,index) in packs">
<div class="col-lg-3">
<label>SKU: #{{ index }}</label>
<input v-model="pack.sku" type="text" name="name" class="form-control m-input" placeholder="SKU">
</div>
<div class="col-lg-3">
<label>Unit:</label>
<select class="form-control select2 #{{ index }}" name="unit" v-model="pack.unit" >
<option value="0">KG</option>
<option value="1">ML</option>
<option value="2">Liter</option>
</select>
</div>
<div class="col-lg-3">
<label>Size:</label>
<input v-model="pack.size" type="number" name="name" class="form-control m-input" placeholder="Size">
</div>
<div class="col-lg-3">
<label>Barcode:</label>
<input v-model="pack.barcode" type="number" name="barcode" class="form-control m-input" placeholder="Barcode">
</div>
</div>

you need to reload select2.
html markup:
<select class="form-control select2 #{{ index }}" name="unit" v-model="pack.unit" id="unit">
<option value="0">KG</option>
<option value="1">ML</option>
<option value="2">Liter</option>
</select>
Vuejs code:
...
components: {
},
mounted() {
setTimeOut(() => {
let unit = $('#unit'); // or document.querySelector('#unit');
unit.select2();
}, 100);
},

Related

how to make selected option using enum in laravel?

this is my code, how to make the selected option value in the edit form using enum data in the database? this is not working it just view the select option, not with id-data
this the code blade
<!-- Modal edit -->
#foreach($daftar_pelanggan as $pelanggan)
<div class="modal fade" id="editModal-{{ $pelanggan->id }}" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title mb-0" id="editModalLabel">Update Data Pelanggan</h5>
</div>
<div class="modal-body">
<!-- Card body -->
<form role="form" action="{{ route('daftar_pelanggan.update') }}" method="POST" id="editForm">
#csrf
#method('PUT')
<!-- Input groups with icon -->
<div class="form-group row">
<label for="updateNamaPelanggan" class="col-md-2 col-form-label form-control-label">Nama</label>
<div class="col-md-10">
<input type="hidden" name="id" value="{{ $pelanggan->id }}">
<input class="form-control" type="nama" value="{{ $pelanggan->nama_pelanggan }}" id="updateNamaPelanggan" name="updateNamaPelanggan" required >
</div>
</div>
<div class="form-group row">
<label for="updateAlamat" class="col-md-2 col-form-label form-control-label">Alamat</label>
<div class="col-md-10">
<input class="form-control" type="alamat" value="{{ $pelanggan->alamat }}" id="updateAlamat" name="updateAlamat" required>
</div>
</div>
<div class="form-group row">
<label for="updateNoTelp" class="col-md-2 col-form-label form-control-label">No.Telp</label>
<div class="col-md-10">
<input class="form-control" type="notelp" value="{{ $pelanggan->no_telp }}" id="updateNoTelp" name="updateNoTelp" required>
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<div class="form-group">
<label class="form-control-label" for="updatePoin">POIN</label>
<input type="text" class="form-control" value="{{ $pelanggan->poin }}" id="updatePoin" name="updatePoin">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-control-label" for="status_member">Kategori</label>
<select class="form-control" id="status_member" name="status_member" required="required">
<option value="" disabled selected>- Pilih -</option <option value="silver"{{($pelanggan->status_member === 'silver') ? 'selected' : '' }} >Silver</option>
<option value="gold" {{ ($pelanggan->status_member === 'gold'? 'selected' : '')}}>Gold</option>
<option value="diamond" {{($pelanggan->status_member === 'diamond')? 'selected' : ''}}>Diamond</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="reset" class="btn btn-secondary" data-dismiss="modal">Reset</button>
<button type="submit" class="btn btn-primary">Update Data</button>
</div>
</form>
</div>
</div>
</div>
#endforeach
this is select code this is not working what's wrong with this code?
<option value="" disabled selected>- Pilih -</option <option value="silver"{{($pelanggan->status_member === 'silver') ? 'selected' : '' }} >Silver</option>
<option value="gold" {{ ($pelanggan->status_member === 'gold'? 'selected' : '')}}>Gold</option>
<option value="diamond" {{($pelanggan->status_member === 'diamond')? 'selected' : ''}}>Diamond</option>
</select>
and i edit with this still not working what's wrong with this code?
<select class="form-control" id="status_member-" name="status_member" required="required">
#if($pelanggan->status_member == "silver")
<option value="silver" selected="selected">Silver</option>
<option value="gold">Gold</option>
<option value="diamond">Diamond</option>
#elseif($pelanggan->status_member == "gold")
<option value="silver">Silver</option>
<option value="gold" selected="selected">Gold</option>
<option value="diamond">Diamond</option>
#else
<option value="silver">Silver</option>
<option value="gold" >Gold</option>
<option value="diamond" selected="selected">Diamond</option>
#endif
</select>

How to show a new column after using select2 in laravel?

I have a form and using select2 for filter. I want to show new column by using this select2.
I don't know its possible or not but i want to do this . using jquery or something, can someone reference to me about this? its my form for my input
<form class="form-prevent-multiple-submits" data-toggle="validator" action="{{route('update_sarpras_aduan'),'test'}} " method="post">
#csrf
{{method_field('patch')}}
<div class="form-group">
<label class="control-label" for="title">Nama Unit:</label>
<input type="text" name="nama_unit" id="nama_unit" class="form-control" data-error="Please enter title." required disabled/>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="title">Tanggal Aduan:</label>
<textarea name="created_at" class="form-control" id="tgl_aduan" data-error="Please enter description." readonly ></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="title">Nama Pengadu:</label>
<input type="text" name="nama_pengadu" class="form-control" id="nama_pengadu" data-error="Please enter title." readonly />
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label> Isi Aduan </label>
<textarea name="aduan" id="aduan" class="form-control" rows="3" placeholder="Isi Aduan atau Keluhan ..." readonly ></textarea>
</div>
<div class="form-group">
<label class="control-label" for="title">Nama Teknisi:</label>
<input type="text" name="nama_teknisi" class="form-control" id="nama_teknisi" data-error="Please enter title." readonly />
<div class="help-block with-errors"></div>
</div>
----------------here this select2---------------------------
<div class="form-group">
<label>Pilih Inventaris</label>
<select class="form-control select2bs4" name="alat_id" id="alat_id" style="width: 100%;" aria-hidden="true">
#foreach($inven as $id => $item )
<option value="{{ $id }}">{{ $item }} </option>
#endforeach
</select>
</div>
--------------------------------------------------
<div class="form-group">
<label>Status Saat Ini (Jangan Lupa Diganti)</label>
<select name="status" id="status" class="form-control">
<option value="Tindakan Lanjutan">Tindakan Lanjutan</option>
<option value="Selesai">Selesai</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label> Tindakan Pelaksana </label>
<textarea name="tindakan" id="tindakan" class="form-control" rows="3" placeholder="Isi Tindakan Yang dilakukan" required ></textarea>
</div>
<div class="form-group">
<label>Kondisi Alat </label>
<select name="status_alat" id="status_alat" class="form-control">
<option value="Baik">Baik</option>
<option value="Rusak Ringan">Rusak Ringan</option>
<option value="Rusak Berat">Rusak Berat</option>
</select>
<div class="help-block with-errors"></div>
</div>
<input type="hidden" name="id" id="id" value="">
<input type="hidden" name="user_id" id="user_id" value="">
<input type="hidden" name="ipsrs_id" id="ipsrs_id" value="">
<input type="hidden" name="teknisi_id" id="teknisi_id" value="">
<input type="hidden" name="ended_at" id="ended_at" value="">
<div class="form-group">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" id="button" class="btn btn-success crud-submit-edit button-prevent-multiple-submits">
<i class="spinner fa fa-spinner fa-spin" ></i>
Submit</button>
</div>
</form>
after using this select2 , will showing a new form . can someone references to me about this ?
//select input
<div class="form-group">
<label>Pilih Inventaris</label>
<select class="form-control select2bs4" name="alat_id" id="alat_id" style="width: 100%;" aria-hidden="true" onchange="Show()">
#foreach($inven as $id => $item )
<option value="{{ $id }}">{{ $item }} </option>
#endforeach
</select>
</div>
//new form
<div id="divid" style="display:none">
<form method="" action="">
#csrf
</form
<div>
//javascript code
<script>
function Show()
{
var fieldValue = $('#alat_id').val();
if(fieldValue == "")
{
document.getElementById("divid").style.display = 'none';
}
else{
document.getElementById("divid").style.display = 'inline'
}
}
</script>

Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given

I have a form to submit add salarie, the problem here if I delete the function store in controller, it even gives me error instead of giving me error function store does not exist.
SalarieController.php
public function store(request $request){
Salarie::create($request->all());
session()->flash('success','salarie add successfully');
return redirect('salaries');
}
web.php
Route::resource('salaries', 'SalarieController');
create.blade.php
<form action="{{ url('salaries') }}" method="post">
{{ csrf_field() }}
<div class="col-md-12">
<div class="form-group col-md-3 #if($errors->get('matricule')) has-error #endif">
<input type="text" name="matricule" class="form-control" value="{{ old('matricule') }}" placeholder="matricule">
</div>
<div class="form-group col-md-3 #if($errors->get('nom')) has-error #endif">
<input type="text" name="nom" class="form-control" value="{{ old('nom') }}" placeholder="nom">
</div>
<div class="form-group col-md-3 #if($errors->get('prenom')) has-error #endif">
<input type="text" name="prenom" class="form-control" value="{{ old('prenom') }}" placeholder="prenom">
</div>
<div class="form-group col-md-3 #if($errors->get('cin')) has-error #endif">
<input type="text" name="cin" class="form-control" value="{{ old('cin') }}" placeholder="cin">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3 ">
<input type="date" name="daten" class="form-control" value="{{ old('daten') }}" placeholder="date naissance">
</div>
<div class="form-group col-md-3">
<select class="form-control" name="situationf">
<option>celebataire</option>
<option>marie</option>
</select>
</div>
<div class="form-group col-md-3">
<input type="text" name="nbree" class="form-control" value="{{ old('nbree') }}" placeholder="nombre d'enfant">
</div>
<div class="form-group col-md-3">
<input type="text" name="cnss" class="form-control" value="{{ old('cnss') }}" placeholder="matricule CNSS">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3 #if($errors->get('salairenet')) has-error #endif">
<input type="text" name="salairenet" class="form-control" value="{{ old('salairenet') }}" placeholder="salaire net">
</div>
<div class="form-group col-md-3 #if($errors->get('unite')) has-error #endif">
<select class="form-control" name="unite">
<option>Heure</option>
<option>Jour</option>
<option>Mois</option>
</select>
</div>
<div class="form-group col-md-3">
<input type="text" name="hs" class="form-control" value="{{ old('hs') }}" placeholder="tarif HS">
</div>
<div class="form-group col-md-3">
<input type="date" name="datee" class="form-control" value="{{ old('datee') }}" placeholder="date embouche">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3">
<select class="form-control" name="fonction_id">
<option></option>
#foreach($fonctions as $fonction)
<option value="{{ $fonction->id }}">{{ $fonction->fonction}}</option>
#endforeach
</select>
</div>
<div class="form-group col-md-3">
<input type="text" name="primer" class="form-control" value="{{ old('primer') }}" placeholder="prime rendement">
</div>
<div class="form-group col-md-3">
<input type="text" name="primel" class="form-control" value="{{ old('primel') }}" placeholder="prime de longement">
</div>
<div class="form-group col-md-3">
<input type="text" name="primet" class="form-control" value="{{ old('primet') }}" placeholder="prime de transport">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3">
<select class="form-control" name="chantier_id">
<option></option>
#foreach($chantiers as $chantier)
<option value="{{ $chantier->id }}">{{ $chantier->chantier}}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-2 col-md-offset-5">
<button type="submit" class="btn btn-theme btn-lg" value="submit">Ajouter</button>
</div>
</div>
</form>
Salarie.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Salarie extends Model
{
public function chantier(){
return $this->belongsTo('App\Chantier');
}
protected $guarded = [];
}
I guess you're missing some options values
here
<select class="form-control" name="situationf">
<option>celebataire</option> // must be <option value="celeb_value">celebataire</option>
<option>marie</option> // must be <option value="marie_value">celebataire</option>
</select>
here also
<select class="form-control" name="unite">
<option>Heure</option> // must be <option value="heure_value">Heure</option>
<option>Jour</option> // must be <option value="jour_value">Jour</option>
<option>Mois</option> // must be <option value="mois_value">Mois</option>
</select>
here too
<select class="form-control" name="fonction_id">
<option></option> // remove empty option or set function_id to nullable
#foreach($fonctions as $fonction)
<option value="{{ $fonction->id }}">{{ $fonction->fonction}}</option>
#endforeach
</select>
and here
<select class="form-control" name="chantier_id">
<option></option> // same as function_id
#foreach($chantiers as $chantier)
<option value="{{ $chantier->id }}">{{ $chantier->chantier}}</option>
#endforeach
</select>

The recaptcha is above the button

I have my recaptcha, it's working but the problem that I have it's that the submit button is under the captcha, I mean when I push the submit button I click the captcha too, I have tried with z-index but it does not worrk, how can I fix it?
<form action="{{ url('ticket/store') }}" method="post" id="ticket_form">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<input type="text" class="form-control" placeholder="RUT" name="rut" required="">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Nombre" name="name" required="">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Correo" name="email" required="">
</div>
<div class="form-group">
<input type="number" class="form-control" placeholder="Teléfono" name="phone" required="">
</div>
<div class="form-group">
<select name="case_type" class="form-control" required="">
<option value="">- Tipo de Caso -</option>
<option value="1">Felicitación</option>
<option value="2">Reclamo</option>
<option value="3">Sugerencia</option>
</select>
</div>
<div class="form-group">
<select name="id_branch_office" class="form-control" required="">
<option value="">- Sucursal -</option>
#foreach($branch_offices as $branch_office)
<option value="{{ $branch_office->id_branch_office }}">{{ $branch_office->view_name }}</option>
#endforeach
</select>
</div>
<div class="form-group">
<textarea placeholder="Mensaje" class="form-control" rows="5" name="message" required=""></textarea>
</div>
<center>{!! htmlFormSnippet() !!}</center>
<br>
<button id="send" type="submit" class="btn btn-primary btn-orange">Enviar Mensaje</button>
</form>
You can test it in the next website jisparking.cl
Thanks
If you inspect the page (in Chrome you can do right click -> inspect) and check the box of the generated recaptcha, you can see that it stretches well over the button.
To stop the extra content from overflowing the container, you can add some CSS.
Try this
<center style="overflow: hidden">{!! htmlFormSnippet() !!}</center>

Laravel - Request does not contain my inputs

I have the following form :
<div class="container text-center search-container">
<form id="search-form" action="" method="post">
<div class="nopadding col-xs-12 col-sm-2">
<select name="huge" class="form-control input-block-level selectpicker search-selector" data-style="btn-default btn-fill btn-block">
<option disabled>Search in...</option>
<option value="1" selected>foo1</option>
<option value="2">foo2</option>
<option value="3">foo3</option>
</select>
</div>
<div class="nopadding col-xs-12 col-sm-8">
<input type="text" class="form-control input-block-level search-bar" id="searchbar">
</div>
{{ csrf_field() }}
<div class="nopadding col-xs-12 col-sm-2">
<button class="btn btn-info btn-fill search-button input-block-level" type="submit">Search</button>
</div>
</form>
</div>
I use bootstrap-select for the select element.
This calls a method in my controller, however when I do a dd($request->all(), here is what I do obtain :
array:2 [▼
"huge" => "1"
"_token" => "somethingReallyLongAndBoring"
]
Basically, I am not able to retrieve my inputs. Any idea what I did wrong ?
You have to add name attribute to the input field.
<input type="text" class="form-control input-block-level search-bar" id="searchbar" name="searchbar">

Resources