Html.RenderPartial in Asp.Net Mvc 4 doesn't work fine - asp.net-mvc-4

I have view that display Companies' CardView.Every card has add new BankAccount button to display "Add new bank account" modal popup. My view as follow:
#for (int i = 0; i < Model.Companies.Count(); i += 3)
{
<div class="row-fluid">
<div class="span4">
<div class="box corner-all">
<div class="box-header grd-white">
<div class="header-control">
<div>
<ul class="breadcrumb-nav pull-right">
<li class="btn-group">
<a href="#" class="btn btn-small btn-link dropdown-toggle" data-toggle="dropdown">
<i class="icofont-cogs"></i>Controls
<i class="icofont-caret-down"></i>
</a>
<ul class="dropdown-menu">
<li>Add new bankaccount</li>
<li>#Html.ActionLink("Edit", "Edit", Model.Companies.ElementAt(i), new { target = "_blank" })</li>
</ul>
</li>
</ul>
#{Html.RenderPartial("BankCreateModal", new BankAccountCreateViewModel { BankAccount = new Invoice.Model.BankAccount(), TaxTypes = Model.TaxTypes, CompanyID = Model.Companies.ElementAt(i).ID });}
</div>
</div>
<span>#Model.Companies.ElementAt(i).ShortName</span>
</div>
<div class="box-body">
<table>
<tr>
<td rowspan="2">
<div class="resume-photo">
<img src="~/Content/img/LogoFiles/#Model.Companies.ElementAt(i).LogoFile" style="width: 50px; height: 45px;"/>
</div>
</td>
<td>#Model.Companies.ElementAt(i).FullName</td>
</tr>
</table>
<div class="alert alert-info">
#*<button type="button" class="close" data-dismiss="alert">×</button>*#
<strong></strong>#Model.Companies.ElementAt(i).CompanyDescription
</div>
</div>
<div style="text-align: center; padding-left: 22px;">
<div class="thumbnails pricing-table color-black">
<div class="span3 active grd-white box-shadow" style="width: 270px;">
<div class="bank_details_expand">
<div class="features">
<div id="slideshow-area">
<div id="slideshow-previous"></div>
<div id="slideshow-next"></div>
<div id="slideshow-scroller">
<div id="slideshow-holder">
#foreach (var bank in Model.BankAccounts.ElementAt(i))
{
<div class="slideshow-content">
<div class="alert alert-info">
<!--box body-->
<div class="box-body">
<!-- Button to trigger modal -->
<!-- Modal -->
#{Html.RenderPartial("BankEditModal", new BankAccountEditViewModel { BankAccount = bank, TaxTypes = Model.TaxTypes });}
</div>
<!--/box body-->
<ul style="text-align: left;">
<li></li>
<li><span style="font-weight: bolder; color: #0B72E0">Bank Name:</span>
<span style="font-style: italic;">#bank.BankName</span></li>
<li><span style="font-weight: bolder; color: #0B72E0">Corr. Account:</span>
<span style="font-style: italic;">#bank.CorrespondentAccount</span> </li>
<li><span style="font-weight: bolder; color: #0B72E0">IBAN:</span>
<span style="font-style: italic;">#bank.IBAN </span></li>
<li><span style="font-weight: bolder; color: #0B72E0">Code:</span>
<span style="font-style: italic;">#bank.Code</span></li>
<li><span style="font-weight: bolder; color: #0B72E0">SWIFT:</span>
<span style="font-style: italic;">#bank.SWIFT</span></li>
<li><span style="font-weight: bolder; color: #0B72E0">Tax Type:</span>
<span style="font-style: italic;">#bank.Tax.Presentage % </span></li>
</ul>
</div>
</div>
}
</div>
</div>
</div>
</div>
</div>
<div class="bank-details-control">
<div class="footer grd-white" data-box="expandBank">
<div>Bank Details</div>
<i class="icofont-chevron-down"></i>
#*<a class="btn btn-block btn-warning" data-box="expandBank">Bank Details</a>*#
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#if (Model.Companies.Count() - 1 > i)
{
#{Html.RenderPartial("BankCreateModal", new BankAccountCreateViewModel { BankAccount = new Invoice.Model.BankAccount(), TaxTypes = Model.TaxTypes, CompanyID = Model.Companies.ElementAt(i + 1).ID });}
}
#if (Model.Companies.Count() - 2 > i)
{
#{Html.RenderPartial("BankCreateModal", new BankAccountCreateViewModel { BankAccount = new Invoice.Model.BankAccount(), TaxTypes = Model.TaxTypes, CompanyID = Model.Companies.ElementAt(i + 2).ID });}
}
}
PartialView for create bankaccount as follow
#model InvoiceModel.HelperClasses.BankAccountCreateViewModel
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<div id="MyCreate" class="modal hide fade" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2 id="myModalLabel">Bank Account</h2>
</div>
<div class="modal-body">
#using (Ajax.BeginForm("CreateModal", new AjaxOptions { UpdateTargetId = "Createmodal", HttpMethod = "Post" }))
{
#Html.ValidationSummary(true)
#Html.HiddenFor(model => model.CompanyID)
#Html.HiddenFor(model => model.TaxTypes)
<div class="control-group">
#Html.LabelFor(model => model.BankAccount.BankName)
#Html.EditorFor(model => model.BankAccount.BankName)
#Html.ValidationMessageFor(model => model.BankAccount.BankName)
</div>
<div class="control-group">
#Html.LabelFor(model => model.BankAccount.CorrespondentAccount)
#Html.EditorFor(model => model.BankAccount.CorrespondentAccount)
#Html.ValidationMessageFor(model => model.BankAccount.CorrespondentAccount)
</div>
<div class="control-group">
#Html.LabelFor(model => model.BankAccount.IBAN)
#Html.EditorFor(model => model.BankAccount.IBAN)
#Html.ValidationMessageFor(model => model.BankAccount.IBAN)
</div>
<div class="control-group">
#Html.LabelFor(model => model.BankAccount.Code)
#Html.EditorFor(model => model.BankAccount.Code)
#Html.ValidationMessageFor(model => model.BankAccount.Code)
</div>
<div class="control-group">
#Html.LabelFor(model => model.BankAccount.SWIFT)
#Html.EditorFor(model => model.BankAccount.SWIFT)
#Html.ValidationMessageFor(model => model.BankAccount.SWIFT)
</div>
<div class="control-group">
#Html.LabelFor(model => model.BankAccount.TaxID, new { #class = "control-label" })
<div class="controls">
#Html.DropDownListFor(model => model.BankAccount.TaxID, new SelectList(Model.TaxTypes, "ID", "Name"), new { data_placeholder = "Select Tax Type", data_form = "select2" })
#Html.ValidationMessageFor(model => model.BankAccount.TaxID)
</div>
</div>
<button class="btn btn-primary">Save changes</button>
}
</div>
<div class="modal-footer">
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
So, When I click SaveChanges button I can create new bank for first company, but when click for other company in bankaccountcontroller my CompanyID is the same with first company. My HTTPPOST action as follow
[HttpPost]
public ActionResult CreateModal(BankAccountCreateViewModel bank)
{
bank.BankAccount.CompanyID = bank.CompanyID;
bankRepository.SaveBankAccount(bank.BankAccount);
return RedirectToActionPermanent("Index");
}
How can I fix this problem? I need second or other companyID, not first.

Related

The requested module does not provide an export named vuejs 3

I have tried to use export default and export default legend but it still got error
The requested module '/src/legends.js?t=1637071' does not provide an export named 'legend'
in console log, how can I fix this problem?
Thank you!!
legends.js
import axios from "axios";
const API_URL = "http://localhost:8000/api";
function add(url, type) {
axios
.post(`${API_URL}/${url}`, this.newRole)
.then((res) => {})
.catch((error) => {
console.log("ERRRR:: ", error.response.data);
});
}
function remove(url, type) {
axios
.post(`${API_URL}/${url}`, this.newRole)
.then((res) => {})
.catch((error) => {
console.log("ERRRR:: ", error.response.data);
});
}
export default legend
manageRoles.vue
<template>
<div class="col-md-12">
<div class="card">
<div class="card-header d-flex flex-row">
<h4 class="card-title align-self-center">Roles Manager</h4>
<button
class="btn btn-success btn-fab btn-icon btn-round mb-3 ml-2"
data-toggle="modal"
data-target="#addRoleModal">
<i class="icon-simple-add"></i>
</button>
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Role Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="role in roles" :key="role.id">
<td>
{{ role.id }}
</td>
<td>
{{ role.name }}
</td>
<Buttons />
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- MODALS -->
<!-- ADD NEW ROLE MODAL -->
<div
class="modal modal-black fade" id="addRoleModal"
tabindex="-1" role="dialog" aria-labelledby="addRoleModal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add new role</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="icon-simple-remove"></i>
</button>
</div>
<form class="form-horizontal">
<div class="modal-body">
<div class="d-flex flex-row">
<label class="col-md-4 col-form-label">Role name</label>
<div class="col-md-6">
<div class="form-group">
<input type="name" name="name" class="form-control"
v-model="newRole.name" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
Cancel
</button>
<button type="submit" class="btn btn-primary" #click.stop.prevent="addRole()">
Add new role
</button>
</div>
</form>
</div>
</div>
</div>
<!-- END ADD NEW ROLE MODAL -->
<!-- REMOVE ROLE MODAL -->
<div class="modal modal-black fade" id="roleRemoveModal"
tabindex="-1" role="dialog" aria-labelledby="roleRemoveModal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="roleRemoveModal">
Confirm delete role
<strong class="text-primary">
{{ roleInfo.name }}
</strong>
</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="icon-simple-remove"></i>
</button>
</div>
<div class="modal-body h4 text-white text-center mt-4">
Really want to delete role
<strong class="text-danger">
{{ roleInfo.name }}
</strong>?
</div>
<div class="modal-footer d-flex flex-row">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
Cancel
</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" #click="removeRole()">
Delete role
</button>
</div>
</div>
</div>
</div>
<!-- END REMOVE ROLE MODAL -->
<!-- END MODALS -->
</template>
<script>
import Buttons from "../components/cores/Buttons.vue";
import { legend } from "/src/legends.js";
export default {
name: "manageRoles",
components: { Buttons },
data() {
return {
roles: [],
newRole: {
name: null,
},
roleInfo: {
id: 0,
name: "",
},
};
},
methods: {
addRole() {
legend.add(`roles/createRole`);
this.$router.push("/manager/roles");
},
removeRole() {
legend.remove(`roles/createRole`);
this.$router.push("/manager/roles");
},
},
mounted() {
this.refreshRoles();
},
};
</script>
export default is default export, as the name implies. Regardless of how the variable that holds a value of default export is called, it's supposed to be imported as default import, not named import with brackets:
const legend = ...;
export default legend;
and
import legendCanBeImportedUnderAnyName from "/src/legends.js"
Alternatively, it can be made named export, it also needs to be imported as such:
export const legend = ...;
and
import { legend } from "/src/legends.js"
Try this.import * as legend from "/src/legends.js";

How to use Form in FOREACH with ASP.NET

The problem is when I use the form inside ModalDialog and put Modal in a loop. If I have several records.
The problem is when I use the form inside ModalDialog and put Modal in a loop. If I have several records.
When I select each record, only the first record information is sent. Please check and help
When I select each record, only the first record information is sent. Please check and help
#{ var count = 0;}
#foreach (var item in Model.ProjectViewModels)
{
<tr>
#if (item.PersonState == 1)
{
<td style="width:35px; color:black;">
<span class="badge badge-success" style="width:50px; border-radius:15px;">
فعال
</span>
</td>
}
else
{
<td style="width:35px; color:black;">
<span class="badge badge-danger" style="width:50px; border-radius:15px;">
غیرفعال
</span>
</td>
}
<td>#item.PersonName #item.Family</td>
<td>#item.PersonCode</td>
<td>#item.projectName</td>
<td style="width:300px">
#if (item.PersonState == 1)
{
<div class="text-center row d-flex justify-content-between">
<div style="margin-top:3px">
<a class="fa fa-edit" style="font-size:28px;color:darkblue" asp-controller="Home" asp-action="updatePerson" asp-route-id="#item.PersonID"></a>
</div>
<form asp-controller="Home" asp-action="RemovePerson" asp-route-id="#item.PersonID" method="post">
<a value="submit" class="fa fa-trash-o ajax_delete1 " style="font-size: 27px; color: red; cursor: pointer;"> </a>
</form>
<div>
<a class="btn btn-sm btn-outline-primary" asp-controller="Home" asp-action="detailsPerson" asp-route-id="#item.PersonID">جزئیات</a>
<a class="btn btn-sm btn-outline-secondary" asp-controller="Report" asp-action="SingelGhrardad" asp-route-id="#item.PersonID">قرارداد</a>
<a class="btn btn-sm btn-outline-danger" data-toggle="modal" data-target="#myModal#(count)">ترک کار</a>
<!-- The Modal -->
<div class="modal fade" id="myModal#(count)">
<div class="modal-dialog ">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">ثبت تاریخ ترک کار پرسنل</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
<form asp-controller="Home" asp-action="PersonTarkKar" asp-route-id="#item.PersonID" asp-route-PersonNewState="0" method="post">
<div class="row">
<div class="col-md-5 col-xs-12">
<label>تاریخ ترک کار</label>
<div class="input-group" style="padding-left:9px; padding-right:9px;">
<div class="input-group-addon"
style="border:1px solid gray; padding:6px">
<span> <i class="right fa fa-calendar"></i></span>
</div>
<input id="calender1" name="calender1" type="text" required autocomplete="off" class="form-control" />
</div>
</div>
</div>
<button class="btn btn-dark mt-5" type="submit">ثبت تاریخ</button>
</form>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">بستن</button>
</div>
</div>
</div>
</div>
#{count++;}
</div>
</div>
}
#section Scripts{
<script>
$('#calender1').MdPersianDateTimePicker({
targetTextSelector: '#calender1',
});
</script>
}
When I select each record, only the first record information is sent. Please check and help
That is because your modal ids are always the same.
You need change your view like below:
#{ var i = 0; }
#foreach (var item in Model.ProjectViewModels)
{
<tr>
//...
<td style="width:300px">
#if (item.PersonState == 1)
{ //change here......
<a class="btn btn-sm btn-outline-danger"
data-toggle="modal" data-target="#myModal_#i">ترک کار</a>
<!-- The Modal -->
//change here...........
<div class="modal fade" id="myModal_#i">
<div class="modal-dialog ">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">ثبت تاریخ ترک کار پرسنل</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
//...
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">بستن</button>
</div>
</div>
</div>
</div>
}
</td>
</tr>
i++; //add this.......
}
Update:
You need loop the js like below:
#section Scripts
{
<link href="/lib/md.bootstrappersiandatetimepicker/dist/jquery.md.bootstrap.datetimepicker.style.css" rel="stylesheet" />
<script src="/lib/md.bootstrappersiandatetimepicker/dist/jquery.md.bootstrap.datetimepicker.js"></script>
<script>
for (j = 0; j < #Model.ProjectViewModels.Count(); j++)
{
$('#calender_'+j).MdPersianDateTimePicker({
targetTextSelector: '#calender_'+ j,
});
}
</script>
}
Change:
<input id="calender" name="calender1" type="text" required autocomplete="off" class="form-control" />
To:
<input id="calender_#i" name="calender1" type="text" required autocomplete="off" class="form-control" />

The Laravel 8 crud that uses the modal does not add data to the database

I work on one project for college and I have one problem...Does anyone know why I don't want to enter data into the database after adding by modal method. It is also not updated. And it doesn’t throw out a single mistake. Namely, I would like to have a crud operation on the same page, ie not to switch to another url when clicking on edit, add ... Just to add that the delete button is the only one of these three ...
index.blade.php
<?php
use App\Models\User;
use App\Models\Client;
use App\Models\Event;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap CRUD Data Table for Database with Modal Form</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<div class="container">
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-6">
<h2>Uredi <b>klijente</b></h2>
</div>
<div class="col-sm-6">
<i class="material-icons"></i> <span>Dodaj novog klijenta</span>
</div>
</div>
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Ime</th>
<th>Prezime</th>
<th>Datum rođenja</th>
<th>Email roditelja</th>
<th>Tel.roditelja</th>
<th>U terapiji?</th>
<th>Dijagnoza</th>
<th>Komentar</th>
<th>Logoped</th>
<th>Akcije</th>
</tr>
</thead>
<tbody>
#foreach($clients as $client)
<tr>
<td>{{$client->name}}</td>
<td>{{$client->lastname}}</td>
<td>{{$client->date_of_birth}}</td>
<td>{{$client->email}}</td>
<td>{{$client->telephone}}</td>
<td>{{$client->in_therapy}}</td>
<td>{{$client->diagnosis}}</td>
<td>{{$client->comments}}</td>
<td>{{$client->therapists_id}}</td>
<td>
<i class="material-icons" data-toggle="tooltip" title="Edit"></i>
<i class="material-icons" data-toggle="tooltip" title="Delete"></i>
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
<!-- add Modal HTML -->
<div id="addEmployeeModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form>
<div class="modal-header">
<h4 class="modal-title">Dodaj klijenta</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
{!! Form::open(['action' =>['ClientsController#store',''],'method'=>'POST','style'=>'width:50%',]) !!}
{{csrf_field()}}
<div class="modal-body">
<div class="form-group">
{{Form::label('name','Ime')}}
{{Form::text('name','',['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('lastname','Prezime')}}
{{Form::text('lastname','',['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('date_of_birth','Datum rođenja')}}
{{Form::date('date_of_birth','',['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('email','Email roditelja')}}
{{Form::text('email','',['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('telephone','Tel. roditelja')}}
{{Form::text('telephone','',['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('in_therapy','U terapiji?')}}<br/>
{{Form::checkbox('in_therapy','Da',['class'=>'form-control'])}}Da<br/>
{{Form::checkbox('in_therapy','Ne',['class'=>'form-control'])}}Ne<br/>
</div>
<div class="form-group">
{{Form::label('diagnosis','Dijagnoza')}}
{{Form::textarea('diagnosis','',['class'=>'form-control','rows' => 3, 'cols' => 170,])}}
</div>
<div class="form-group">
{{Form::label('comments','Komentari')}}
{{Form::textarea('comments','',['class'=>'form-control','rows' => 3, 'cols' => 170,])}}
</div>
<div class="form-group">
{{Form::label('user_id', 'Logoped')}}<br/>
{{Form::select('user_id', $sp_therapist, null, ['class' => 'form-control','placeholder' => 'Izaberite logopeda'])}}
</div>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Odustani">
<input type="submit" class="btn btn-success" value="Dodaj">
</div>
{!!Form::close()!!}
</div>
</div>
</div>
<!-- Edit Modal HTML -->
<div id="editEmployeeModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form>
<div class="modal-header">
<h4 class="modal-title">Edit Employee</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
{!! Form::open(['action' =>['ClientsController#update',''],'method'=>'POST','style'=>'width:50%',]) !!}
{{csrf_field()}}
<div class="modal-body">
<div class="form-group">
{{Form::label('name', 'Ime')}}
{{Form::text('name', $client->name, ['class' => 'form-control'])}}
</div>
<div class="form-group">
{{Form::label('lastname', 'Prezime')}}
{{Form::text('lastname', $client->lastname, ['class' => 'form-control', 'placeholder' ])}}
</div>
<div class="form-group">
{{Form::label('date_of_birth', 'Datum rođenja')}}
{{Form::date('date_of_birth', $client->date_of_birth, ['class' => 'form-control', 'placeholder' => 'Unesite datum rođenja djeteta'])}}
</div>
<div class="form-group">
{{Form::label('email', 'Email')}}
{{Form::text('email', $client->email, ['class' => 'form-control', 'placeholder' => 'Unesite email roditelja'])}}
</div>
<div class="form-group">
{{Form::label('telephone', 'Kontakt broj:')}}
{{Form::text('telephone', $client->telephone, ['class' => 'form-control', 'placeholder' => 'Unesite kontakt broj'])}}
</div>
<div class="form-group">
#if($client->in_therapy != 1)
<div class="form-group">
{{Form::label('in_therapy', 'U terapiji')}}<br>
#if($client->in_therapy == "Da")
{{Form::checkbox('in_therapy', 'Da',$client->in_therapy)}} Da <br>
{{Form::checkbox('in_therapy', 'Ne','')}} Ne<br>
#elseif($client->in_therapy == "Ne")
{{Form::checkbox('in_therapy', 'Da',)}} Da<br>
{{Form::checkbox('in_therapy', 'Ne',$client->in_therapy)}} Ne <br>
#endif
</div>
</div>
#else
<div class="form-group">
{{Form::label('in_therapy', 'U terapiji?')}}<br>
#if($client->in_therapy == "Da")
{{Form::text('in_therapy',$client->in_therapy,['class'=>'form-control','readonly '])}} <br>
#elseif($client->in_therapy == "Ne")
{{Form::text('in_therapy',$client->in_therapy,['class'=>'form-control','readonly '])}} <br>
</div>
#endif
<div class="form-group">
{{Form::label('in_therapy', 'U terapiji?')}}<br>
#if($client->in_therapy == "Da")
{{Form::text('in_therapy',$client->in_therapy,['class'=>'form-control','readonly '])}} <br>
#elseif($client->in_therapy == "Ne")
{{Form::text('in_therapy',$client->in_therapy,['class'=>'form-control','readonly '])}} <br>
</div>
#endif
#endif
<div class="form-group">
{{Form::label('diagnosis', 'Dijagnoza?')}}<br/>
{{Form::textarea('diagnosis', $client->diagnosis, ['class' => 'form-control', 'rows' => 5, 'cols' => 170])}}
</div>
<div class="form-group">
{{Form::label('comments', 'Komentari')}}<br/>
{{Form::textarea('comments', $client->comments, ['class' => 'form-control', 'rows' => 5, 'cols' => 170, 'placeholder' => 'Unesite popratne komentare'])}}
</div>
<div class="form-group">
{{Form::label('therapists_id', 'Logoped')}}
{{Form::select('therapists_id', $sp_therapist, $client->therapists_id,['class' => 'form-control', 'placeholder' => 'Izaberite logopeda'])}}
</div>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<input type="submit" class="btn btn-info" value="Save">
</div>
{!!Form::close()!!}
</div>
</div>
</div>
<!-- Delete Modal HTML -->
<div id="deleteEmployeeModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
{!!Form::open(['action' =>['ClientsController#destroy', $client->id], 'method' => 'POST'])!!}
<div class="modal-header">
<h4 class="modal-title">Izbriši klijenta</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>Da li ste sigurni da želite izbrisati ovog klijenta?</p>
<p class="text-warning"><small style="color: #000">Ova akcija se ne može poništiti</small></p>
</div>
<div class="modal-footer">
#method('DELETE')
<input type="button" class="btn btn-default" data-dismiss="modal" value="Odustani">
<input type="submit" class="btn btn-danger" value="Izbriši">
</div>
{!!Form::close()!!}
</div>
</div>
</div>
</body>
</html>
#endsection
this is controller for store and edit.
public function store(Request $request)
{
$this->validate($request,[
'name' => 'required',
'lastname' => 'required',
'date_of_birth' => 'required',
'telephone' => 'required'
]);
$client = new Client;
$client->name = $request->input('name');
$client->lastname = $request->input('lastname');
$client->date_of_birth = $request->input('date_of_birth');
$client->email = $request->input('email');
$client->telephone = $request->input('telephone');
$client->in_therapy = $request->input('in_therapy');
$client->diagnosis = $request->input('diagnosis');
$client->comments = $request->input('comments');
$client->therapists_id = $request->input('user_id');
$client->save();
return redirect('/clients')->with('success', 'Klijent je unesen');
}
public function edit($id)
{
$sp_therapist = DB::table('users')->pluck('name', 'id');
$client = Client::find($id);
return view('clients.edit')->with('client',$client)->with('sp_therapist', $sp_therapist);
}
and this is web.php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\FullCalenderController;
use App\Http\Controllers\Auth\RegisterController;
Auth::routes();
Route::group(['middleware' => 'auth'], function () {
Route::get('/','PagesController#index');
Route::get('/dashboard', 'DashboardController#index')->name('dashboard');
Route::get('/register', 'Auth\RegisterController#create')->name('register');
Route::resource('clients','ClientsController');
//CALENDAR
Route::get('schedule', [FullCalenderController::class, 'index']);
Route::post('schedule/action', [FullCalenderController::class, 'action']);
});
thanks
Check that the Modals you're using have the $fillable property with the values you want to insert, something like this:
class User extends Model {
protected $fillable = ['name', 'lastname', 'email']
}
otherwise Eloquent doesn't allow you to inject the inputs.
first if u use laravel 8 use this on ur web.php
use App\Http\Controllers\ClientsController;
Route::resource('clients',[ClientsController::class]);
and in ur index file set form action to route('clients.store') , use route name
in ur store controller try to dd($request) to see the respond, if u still have any problem, let us know

After obtaining more data the open panel is not correct

When loading the panels the first time and opening the panel in the third position. Everything is Ok.
When loading more elements, the panel that opens is not correct but it is still the one in the third position.
<div id="load-conversation">
<div class="row" style="margin-bottom: 10px;" v-show="referencesList.length >0">
<div class="col-md-12 text-center">
<button v-on:click="getEmails" class="btn btn-sm btn-blue">Cargar más</button>
</div>
</div>
<div class="panel panel-info" v-for="email in emails">
<!-- Head Panel-->
<div class="panel-heading" v-bind:class=" email.incoming ? 'white-inbox' : 'blue-reply'"
data-toggle="collapse" :href="`#collapse-new${email.id}`">
<!--Email Title-Button -->
<div class="row">
<div class="col-md-8">
<h5 v-if="email.incoming"><span class="fas fa-reply" aria-hidden="true"></span> ${email.sender_name}</h5>
<h5 v-else><span class="fas fa-share-square" aria-hidden="true"></span> ${email.sender_name}</h5>
</div>
</div>
</div>
<!--Body Panel-->
<div :id="`collapse-new${email.id}`" class="panel-collapse collapse">
<div class="panel-body">
<!--Email Head-->
<div class="container-fluid">
<div class="row">
<strong>SUBJECT: </strong><span class="text-info">${email.subject}</span></br>
<strong>FROM: </strong><span class="text-info">${email.sender_email}</span></br>
<strong>TO: </strong><span class="text-info"><span v-for="to in email.to">${to.email}, </span></span></br>
<strong>DATE: </strong><span class="text-info">${email.date}</span></br>
<strong v-if="email.cc.length > 0">CC: </strong><span class="text-info"><span v-for="cc in email.cc">${cc.email}, </span></span>
</div>
</div>
<br>
<!--Email Body-->
<div class="row container-fluid">
<div class="list-group-item"v-html="email.content_html">
</div>
<div>
<div class="bs-component">
<ul class="pager">
<li class="previous" data-toggle="collapse" :data-target="`#open-details-new${email.id}`">
<a href="javascript:void(0)">
<span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span>
</a>
</li>
</ul>
</div>
<div :id="`open-details-new${email.id}`" class="collapse" v-html="email.complete_html">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
The important thing is to see that the new elements are placed in the order of the old elements, that is, the order is reversed in the list. By only adding the elements without changing the order everything works correctly.
<script>
var loadMore = new Vue({
el: '#load-conversation',
delimiters: ['${', '}'],
data: {
limit : 3,
referencesList : [1,2,3,4,5],
emails : [],
showLoadBtn: true,
},
mounted() {
this.getEmails()
},
methods: {
getEmails(){
axios.post("get_more_emails", { references: this.getReferences() })
.then(response => {
//console.log(response.data);
this.emails = [ ...response.data, ...this.emails ]
}).catch(function (error) {
console.log('error', error)
});
},
getReferences(){
...
}
},
})
</script>

HttpPost doesn't work into Modal Popup in MVC 4

I have view that has CompanyTable partial view. So this partial view has a CreateBankAccount partial view. Last partial view codes are
#model Invoice.Model.BankAccount
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
Launch demo modal
<div id="#Model.TaxID" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
#using (Ajax.BeginForm("CreateModal", "CompanyController", new AjaxOptions { UpdateTargetId = "modal", HttpMethod = "post" }))
{
#Html.ValidationSummary(true)
<fieldset>
<legend>BankAccount</legend>
#Html.HiddenFor(model => model.ID)
<div class="editor-label">
#Html.LabelFor(model => model.BankName)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.BankName)
#Html.ValidationMessageFor(model => model.BankName)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.CorrespondentAccount)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.CorrespondentAccount)
#Html.ValidationMessageFor(model => model.CorrespondentAccount)
</div>
<input type="submit" value="save" />
</fieldset>
}
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<input type="submit" class="btn btn-primary" value=" Save changes" data-dismiss="modal" />
</div>
</div>
so this partial view is modal popup. My problem is that when I want to creat bankAccount my HttpPost method doesn't work, and I return Index action. How I can fix it?