在该论坛上进行了大量研究之后,但在Internet上的其他地方,“猫都听懂了”。
许多消息都谈到了这个问题,但是我无法纠正我的错误。
我使用相同的表单来添加或修改我的数据。
仅当我要修改数据时,我的表单才出现错误。
Wep.app:
// Gérer les personnes (sociétés, personnes...) photographiées
Route::get('tiers', 'tiersController@afficheliste'); // Fait
Route::get('tiersajouter', 'tiersController@ajouter'); // Fait
Route::post('tiersmodifier', 'tiersController@modifier'); // Fait
Route::post('tiersupdatesql', 'tiersController@updatesql'); // Fait
Route::post('tierssupprimer', 'tiersController@supprimer'); // Fait
Route::post('tiersreactiver', 'tiersController@reactiver'); // Fait
ctrltiersRequest:
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ctrltiersRequest extends FormRequest {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'tiersNom' => 'required|min:5',
'ville' => 'required',
'tiersiptc1' => 'required',
'tiersiptc2' => 'required'
];
}
public function messages() {
return [
'tiersNom.required' => "Le nom est obligatoire",
'tiersNom.min' => "Le nom doit faire au minimum 5 caractères",
'ville.required' => "La ville est obligatoire",
'tiersiptc1.required' => "Le thème principal est obligatoire",
'tiersiptc2.required' => "Le sous-thème est obligatoire"
];
}
}?>
tiersModif.blade:
I can not paste the contents of my blade file into this message. I add it in a reply to this message. I am sorry...
tiersControllers:
public function updatesql(ctrltiersRequest $request) {
//public function updatesql(tiersRequest $request) {
//['tiers_id' => (int)$request->tiersModif],
$tiers = tiers::updateOrCreate(
['tiers_id' => $request->tiersModif],
['tiers_nom' => $request->tiersNom,
'tiers_prenom' => $request->tiersPrenom,
'tiers_societeproduction' => $request->production,
'tiers_ville' => $request->ville,
'tiers_iptc1' => $request->tiersiptc1,
'tiers_iptc2' => $request->tiersiptc2,
'tiers_iptc3' => $request->tiersiptc3]);
// Afficher
return Redirect('tiers');
答案 0 :(得分:0)
刀片文件的内容:
@extends('layouts.app')
@section('style')
<link href="{{ asset('css/grid.css') }}" rel="stylesheet">
<style>
body {
padding-top: 50px;
}
.navbar-template {
padding: 40px 15px;
}
</style>
@endsection
@section('bardemenu')
@include('menu')
@endsection
@section('contenu')
@if ( $Action['Action'] == "Ajouter" )
<h4> Ajouter un tiers (artiste, photographe, club...)</h4>
@if ($errors->any())
<ul>{!! implode('', $errors->all('<li style="color:red">:message</li>')) !!}</ul>
@endif
<form method="POST" action="{!! url('tiersupdatesql') !!}" accept-charset="UTF-8">
<label for="Nom">Nom : </label><input name="tiersNom" type="text" id="tiersNom" maxlength="50" size="50"><br>
<label for="Prenom">Prénom : </label><input name="tiersPrenom" type="text" id="tiersPrenom" maxlength="50" size="50"><br>
<label for="Production">Société de production : </label><input type="radio" name="production" value="0" checked> Non (par défaut) <input type="radio" name="production" value="1"> Oui<br>
@if ( $boiteprod->count()==0 )
<label for="Production">Pas de boite de production dans la base.</label>
@else
<label for="Production">Manager par la boite de production : </label>
<select name="production" id="production">
<option value="">--- choisir une boite de production ---</option>
@foreach ($boiteprod as $bprod)
<option value="{{ $bprod->tiers_id }}">{{ $bprod->tiers_nom }} {{ $bprod->ville_name }} ({{ $bprod->zip_code }})</option>
@endforeach
</select>
@endif
<br>
<label for="ville"> Ville : </label>
<select name="ville" id="ville">
<option value="">--- choisir une ville ---</option>
@foreach ($villes as $ville)
<option value="{{ $ville->ville_id }}">{{ $ville->ville_name }} ({{ $ville->zip_code }}), {{ $ville->namedept }}-{{ $ville->nom_fr_fr }}</option>
@endforeach
</select><br>
<label for="tiersIPTC1">Thème : </label>
<select name="tiersiptc1" id="tiersiptc1">
<option value="0">Choisissez un thème principal</option>
@foreach ($iptc1s as $iptc1)
@if( !empty($MetadataSeance[0]->metadata_Id) )
<option value="{{ $iptc1->IPTC1_Id }}" {{ ($iptc1->IPTC1_NomFR==$MetadataSeance[0]->comadobecategory) ? "selected=selected" : '' }}>{{ $iptc1->IPTC1_NomFR }}</option>
@else
<option value="{{ $iptc1->IPTC1_Id }}">{{ $iptc1->IPTC1_NomFR }}</option>
@endif
@endforeach
</select><label for="tiersIPTC2">, </label>
<select name="tiersiptc2" id="tiersiptc2">
<option value="0">---</option>
@foreach ($iptc2s as $iptc2)
@if( !empty($MetadataSeance[0]->metadata_Id) )
<option value="{{ $iptc2->IPTC2_Id }}" CLASS="{{ $iptc2->IPTC2_IPTC1 }}" {{ ($iptc2->IPTC2_Numero==$MetadataSeance[0]->comadobeiptcSubjectCode ) ? "selected=selected" : '' }}>{{ $iptc2->IPTC2_NomFR }} ({{ $iptc2->IPTC2_Numero }})</option>
@else
<option value="{{ $iptc2->IPTC2_Id }}" CLASS="{{ $iptc2->IPTC2_IPTC1 }}">{{ $iptc2->IPTC2_NomFR }} ({{ $iptc2->IPTC2_Numero }})</option>
@endif
@endforeach
</select><label for="tiersIPTC3">, </label>
<select name="tiersiptc3" id="tiersiptc3">
<option value="">---</option>
@foreach ($iptc3s as $iptc3)
<option value="{{ $iptc3->IPTC3_Id }}" CLASS="{{ $iptc3->IPTC3_IPTC2 }}">{{ $iptc3->IPTC3_NomFR }}</option>
@endforeach
</select>
<br>
{!! csrf_field() !!}
<input type="hidden" name="action" id="action" value="{{ $Action['Action'] }}">
<input type="submit" value="Ajouter">
<a href="{{ url()->previous() }}">Annuler</a>
</form>
@else
<h4> Mettre à jour un tiers (artiste, photographe, club...)</h4>
@if ($errors->any())
<ul>{!! implode('', $errors->all('<li style="color:red">:message</li>')) !!}</ul>
@endif
<form method="POST" action="{!! url('tiersupdatesql') !!}" accept-charset="UTF-8">
<label for="Nom">Nom : </label><input name="tiersNom" type="text" id="tiersNom" maxlength="50" size="50" value="{{ $letiers[0]->tiers_nom }}"><br>
<label for="Prenom">Prénom : </label><input name="tiersPrenom" type="text" id="tiersPrenom" maxlength="50" size="50" value="{{ $letiers[0]->tiers_prenom }}"><br>
<label for="Production">Société de production : </label><input type="radio" name="production" value="0" {{ ($letiers[0]->tiers_societeproduction==0 ) ? "checked" : '' }}> Non <input type="radio" name="production" value="1" {{ ($letiers[0]->tiers_societeproduction==1 ) ? "checked" : '' }}> Oui<br>
@if ( $boiteprod->count()==0 )
<label for="Production">Pas de boite de production dans la base.</label>
@else
<label for="Production">Manager par la boite de production : </label>
<select name="production" id="production">
<option value="">--- choisir une boite de production ---</option>
@foreach ($boiteprod as $bprod)
<option value="{{ $bprod->tiers_id }}" {{ ($bprod->tiers_id==$letiers[0]->tiers_societeproduction ) ? "selected=selected" : '' }}>{{ $bprod->tiers_nom }} {{ $bprod->ville_name }} ({{ $bprod->zip_code }})</option>
@endforeach
</select>
@endif
<br>
<label for="ville"> Ville : </label>
<select name="ville" id="ville">
<option value="">--- choisir une ville ---</option>
@foreach ($villes as $ville)
<option value="{{ $ville->ville_id }}" {{ ($ville->ville_id==$letiers[0]->tiers_ville ) ? "selected=selected" : '' }}>{{ $ville->ville_name }} ({{ $ville->zip_code }}), {{ $ville->namedept }}-{{ $ville->nom_fr_fr }}</option>
@endforeach
</select><br>
<label for="tiersIPTC1">Thème : </label>
<select name="tiersiptc1" id="tiersiptc1">
<option value="0">Choisissez un thème principal</option>
@foreach ($iptc1s as $iptc1)
@if( !empty($letiers[0]->tiers_id) )
<option value="{{ $iptc1->IPTC1_Id }}" {{ ($iptc1->IPTC1_Id==$letiers[0]->tiers_iptc1) ? "selected=selected" : '' }}>{{ $iptc1->IPTC1_NomFR }}</option>
@else
<option value="{{ $iptc1->IPTC1_Id }}">{{ $iptc1->IPTC1_NomFR }}</option>
@endif
@endforeach
</select><label for="tiersIPTC2">, </label>
<select name="tiersiptc2" id="tiersiptc2">
<option value="0">---</option>
@foreach ($iptc2s as $iptc2)
@if( !empty($letiers[0]->tiers_id) )
<option value="{{ $iptc2->IPTC2_Id }}" CLASS="{{ $iptc2->IPTC2_IPTC1 }}" {{ ($iptc2->IPTC2_Id==$letiers[0]->tiers_iptc2 ) ? "selected=selected" : '' }}>{{ $iptc2->IPTC2_NomFR }} ({{ $iptc2->IPTC2_Numero }})</option>
@else
<option value="{{ $iptc2->IPTC2_Id }}" CLASS="{{ $iptc2->IPTC2_IPTC1 }}">{{ $iptc2->IPTC2_NomFR }} ({{ $iptc2->IPTC2_Numero }})</option>
@endif
@endforeach
</select><label for="tiersIPTC3">, </label>
<select name="tiersiptc3" id="tiersiptc3">
<option value="">---</option>
@foreach ($iptc3s as $iptc3)
@if( !empty($letiers[0]->tiers_id) )
<option value="{{ $iptc3->IPTC3_Id }}" CLASS="{{ $iptc3->IPTC3_IPTC2 }}"{{ ($iptc3->IPTC3_Id==$letiers[0]->tiers_iptc3 ) ? "selected=selected" : '' }}>{{ $iptc3->IPTC3_NomFR }}</option>
@else
<option value="{{ $iptc3->IPTC3_Id }}" CLASS="{{ $iptc3->IPTC3_IPTC2 }}">{{ $iptc3->IPTC3_NomFR }}</option>
@endif
@endforeach
</select>
<br>
{!! csrf_field() !!}
<input name="tiersModif" type="hidden" id="tiersModif" value="{{ $letiers[0]->tiers_id }}">
<input type="submit" value="Modifier">
<a href="{{ url()->previous() }}">Annuler</a>
</form>
@endif
@endsection
@section('scripts')
<script src="{{ asset('js/app.js') }}"></script>
<script src="//code.jquery.com/jquery-1.11.3.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-chained/1.0.1/jquery.chained.js"></script>
<script>
$(function() {
$('#tiersiptc2').chained('#tiersiptc1');
$('#tiersiptc3').chained('#tiersiptc2');
});
</script>
@endsection
答案 1 :(得分:0)
您找不到解决我问题的方法吗?
祝你有美好的一天。
埃里克