我正在使用Laravel AdminLTE package为我的应用提供AdminLTE主题。
我根本无法启动模式。如果我将form.blade.php
的内容复制到我的index.blade.php
中,则可行。虽然我编写了我的控制器&我需要它们成为独立的文件。
所以在我的控制器中我有一个函数将服务器端处理的结果返回到我的数据表中,这只是显示表中每个项的生成方式的部分,特别是编辑函数的btn-group:
$data = array();
if (!empty($costcenters)){
foreach ($costcenters as $costcenter){
$editURL = "delete/".$costcenter->id;
$temp['name'] = $costcenter->name;
$temp['code'] = $costcenter->code;
$action = '';
$action .= '
<div class="btn-group">
<a href="'.route("costcenter.edit",$costcenter->id).'" class="btn btn-info modal-content" data-toggle="modal" data-target="#modal"><i class="fa fa-edit"></i></a>
<a href="'.route("costcenter.delete",$costcenter->id).'" type="button" class="btn btn-danger"><i class="fa fa-trash"></i></a>
</div>
';
$temp['action'] = $action;
array_push($data, $temp);
}//end for each
}// end if empty
$recordsTotal = count($recordsTotal);
echo json_encode(array('recordsTotal' => $recordsTotal, 'data' => $data, 'recordsFiltered' => $recordsTotal));
在我的index.blade.php
我真的没有任何重要性或相关性。
我创建了一个form.blade.php
,所以当我点击编辑时,一个路由使用相关控制器中编辑功能所需的数据调用此视图。如果在新选项卡中打开,此视图将作为纯HTML使用。
<div class="modal fade" id="modal" role="dialog">
<div class="modal-dialog" >
@if ($mode == 'edit')
{!! Form::model($costcenter,array('route'=>array('costcenter.update',$costcenter->id),'id'=>'costcenter-form')) !!}
@else
{!! Form::open(array('url'=>'costcenter/store','method'=>'post','data-toggle'=>'validator','id'=>'costcenter-form')) !!}
@endif
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
@if ($mode == 'edit')
Edit {{$costcenter->name}}'s Cost Center
@else
Create Cost Center
@endif
</h5>
<button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true"> ×</span></button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
{!! Form::label('name','Cost Center Name:',['class'=>'control-label']) !!}
{!! Form::text('name',null,['class'=>'form-control','placeholder'=>'Enter Cost Center Name','data-error'=>"Please enter the name of the cost center",'required'=>true]) !!}
</div>
<div class="form-group">
{!! Form::label('code','CostCenter Code:',['class'=>'control-label']) !!}
{!! Form::text('code',null,['class'=>'form-control','placeholder'=>'Cost Center code as it appears in SYSPRO.','data-error'=>"Invalid Cost Center Code.",'required'=>true]) !!}
</div>
</form>
</div>
<div class="modal-footer">
{!! Form::submit('Save',['class'=>'btn btn-primary'])!!}
</div>
</div>
</div>
</div>
任何帮助都将不胜感激。