How to show a new column after using select2 in laravel? - 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>

Related

how to disable input when the value is empty laravel livewire

i am using livewire , laravel 7. Below is the code. How to make sure the input is readonly when the value is empty?
<div class="form-row">
#foreach($serviceOrder as $o)
<div class="col-md-5 mb-3">
<label class="form-control-label" >Service {{ $loop->iteration }} </label>
<input type="text" wire:model="serviceOrder.{{ $loop->index }}.serv.serviceName" class="form-control " readonly>
</div>
<input type="hidden" wire:model="serviceOrder.{{ $loop->index }}.serv.servicePrice" class="form-control col-sm-1 mb-3" readonly>
<div class="col-md-3 mb-3">
<label class="form-control-label" >Weight/Size</label>
<input type="text" name="" value="" wire:model="serviceOrder.{{ $loop->index }}.weightsize" class="form-control">
</div>
<div class="col-md-3 mb-3">
<label class="form-control-label" >Quantity*opt</label>
<input type="text" name="" value="" wire:model="serviceOrder.{{ $loop->index }}.quantity" class="form-control" #if(!$quantity) readonly #endif >
</div>
#endforeach
</div>
the one i am focusing is this part
<div class="col-md-3 mb-3">
<label class="form-control-label" >Quantity*opt</label>
<input type="text" name="" value="" wire:model="serviceOrder.{{ $loop->index }}.quantity" class="form-control" #if(!$quantity) readonly #endif >
</div>
for the input that has no value, should be " ", it is a nullable variable for quantity
try adding this check in the element:
<input type="text" wire:model="serviceOrder.{{ $loop->index }}.quantity" class="form-control" #if(!$serviceOrder[$loop->index]['quantity']) readonly #endif>

PHP Laravel Post action

I have a form page for users informations update but my post function isn't working.I have defined a post method in the blade page and I show the page as a formaction post.This is my code;
#extends('layouts.admin-master')
#section('content')
<form action="post">
<div class="form-row">
<div class="form-group">
<label for="inputAddress2">Ad Soyad</label>
<input type="text" class="form-control" id="inputAddress2" name="name" value="{{ Auth::user()->name }}">
</div>
<br><br>
<div class="form-group">
<label for="inputAddress2">Şirket</label>
<input type="text" class="form-control" id="inputAddress2" name="company">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Email</label>
<input type="text" class="form-control" id="inputAddress" name="email" value="{{ Auth::user()->email }}">
</div>
<div class="form-group">
<label for="inputAddress2">Telefon</label>
<input type="text" class="form-control" id="inputAddress2" name="phone">
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputState">Üyelik Tipi</label>
<select id="inputState" class="form-control">
<option selected>Seçenekler</option>
<option>Bronz Üyelik</option>
<option>Silver Üyelik</option>
<option>Gold Üyelik</option>
</select>
</div>
<div class="form-group col-md-2">
<label class="radio-container m-r-55">Tedarikçi
<input type="radio" checked="checked" name="secim" value="tedarikci">
<span class="checkmark"></span>
</label>
`enter code here` <label class="radio-container">Alıcı
<input type="radio" name="secim" value="alici">
<span class="checkmark"></span>
</label>
</div>
</div>
<form action="{{route('form.add')}}" method="post" enctype="multipart/form-data">
<button type="submit" class="btn btn-primary">Kaydet</button>
</form>
</form>
#endsection
try this:
#extends('layouts.admin-master')
#section('content')
<form action="{{route('form.add')}}" method="post" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group">
<label for="inputAddress2">Ad Soyad</label>
<input type="text" class="form-control" id="inputAddress2" name="name" value="{{ Auth::user()->name }}">
</div>
<br><br>
<div class="form-group">
<label for="inputAddress2">Şirket</label>
<input type="text" class="form-control" id="inputAddress2" name="company">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Email</label>
<input type="text" class="form-control" id="inputAddress" name="email" value="{{ Auth::user()->email }}">
</div>
<div class="form-group">
<label for="inputAddress2">Telefon</label>
<input type="text" class="form-control" id="inputAddress2" name="phone">
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputState">Üyelik Tipi</label>
<select id="inputState" class="form-control">
<option selected>Seçenekler</option>
<option>Bronz Üyelik</option>
<option>Silver Üyelik</option>
<option>Gold Üyelik</option>
</select>
</div>
<div class="form-group col-md-2">
<label class="radio-container m-r-55">Tedarikçi
<input type="radio" checked="checked" name="secim" value="tedarikci">
<span class="checkmark"></span>
</label>
`enter code here` <label class="radio-container">Alıcı
<input type="radio" name="secim" value="alici">
<span class="checkmark"></span>
</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Kaydet</button>
</form>
put this line in your form and it should work :
{{csrf_field()}}
and make sure that your route address is correct too
u can add #csrf above the button

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>

button not responding laravel

i have this page where i have form where the action url are same. My second form work perfectly fine but mu first form doesn't responding when i hit the button or <a>. I've try to switch the <form action="{{url('purchase')}}" method="post") between form, i've try to cut the action on second form and move it to first form still no luck... any idea? here's sum of my code
<form class="px-2 py-2" action="{{ url('purchase') }}" method="post">
{{csrf_field()}}
<div id="items">
</div>
<div class="row mx-1 px-2">
Purchase
</div>
</form>
that's my first form, inside of id="items" purposely empty since i fill it up with javascript
<form id="newItemForm" style="display:none;">
<div class="form-group row" id="item">
<label for="invoice" class="col-sm-2 col-form-label">Supplier</label>
<div class="col-sm-2">
<select class="form-control" onchange="newExisting(this)">
<option value="#" selected>Choose Supplier</option>
<option value="existing">Existing Supplier</option>
<option value="new">New Supplier</option>
</select>
</div>
<div class="col-sm-8" id="existingCompany" style="display:none;">
<div class="row">
<div class="col-sm-4">
<select class="form-control" name="fromE" onchange="localImport(this)">
<option value="#" checked>From</option>
<option value="f" checked>Import</option>
<option value="l" checked>Local</option>
</select>
</div>
<div class="col-sm-8">
<select class="form-control" name="supplier" id="supplierID">
<option value="#">Choose Company</option>
</select>
</div>
</div>
</div>
<div class="col-sm-8" style="display:none;" id="newCompany">
<div class="row">
<div class="col-sm-4">
<select class="form-control" name="fromN">
<option value="#" checked>From</option>
<option value="f" checked>Import</option>
<option value="l" checked>Local</option>
</select>
</div>
<div class="col-sm-4">
<input type="text" name="kind" value="" placeholder="PT, CV, FIRMA" class="form-control">
</div>
<div class="col-sm-4">
<input type="text" name="supplierName" placeholder="Company Name" class="form-control">
</div>
</div>
</div>
</div>
<div id="newItems">
<div class="form-group row" id="item">
<label for="invoice" class="col-sm-2 col-form-label">Item Name</label>
<div class="col-sm-10">
<input type="text" name="item0" class="form-control" placeholder="Item Name" onkeyup="getCompanyGoods(this)">
<span class="text text-danger" style="display:none;" id="existsWarning0">*Item already exists</span>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="taxInvoice">QTY<span class="text-danger">*</span></label>
<input type="number" name="qty0" class="form-control" id="qty0" required onkeyup="calculate(this)">
</div>
<div class="form-group col-md-3">
<label for="inputPassword4">Units<span class="text-danger">*</span></label>
<input type="number" name="units0" class="form-control" id="units0" required onkeyup="calculate(this)">
</div>
<div class="form-group col-md-3">
<label for="inputPassword4">Total</label>
<div class="form-controll font-weight-bold" style="font-size:x-large;" id="total0">IDR0.00</div>
</div>
</div>
</div>
<label class="btn btn-primary" id="newRow" onclick="addRow()">+ Item</label>
<input type="hidden" name="type" value="new">
<input type="hidden" name="nore" value="#" id="nore">
<input type="number" name="totalItem" value="0" id="totalItem">
<button name="button" class="btn btn-danger float-right" >Purchase</button>
</form>
this is my second form and it work perfectly....
Change
Purchase
to
<button type='submit'>Purchase</button>
Because you have used a tag instead of button type "submit"
Purchase
Change it to like this
<button class="btn btn-primary" type="submit"> Purchase </button>

Resources