我有一个模态的表单,我想用laravel验证它,当我把规则我得到一个错误
方法[validateRequire]不存在。
,我认为这是因为模态,
当我做同样的事情但以其他形式出现时,没关系。 我希望错误出现在模态
中模态
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-sm-12 b-r"><h3 class="m-t-none m-b">CREAR SLIDER</h3>
<div class="hr-line-dashed"></div>
{!! Form::open(['method' => 'POST','route' => ['inicio.actualizarSler','id'], 'files' => true,'id'=>'form-editarslider']) !!}
<input type="hidden" id="idslider" name="idslider">
<meta name="csrf-token" content="{{ csrf_token() }}">
<div class="form-group"><label>Titulo</label> <input type="text" id="tituloEditar" name="tituloEditar" placeholder="Ingrese titulo" class="form-control"></div>
<div class="form-group"><label>Subtitulo</label> <input type="text" id="subtituloEditar" name="subtituloEditar" placeholder="Ingrese subtitulo" class="form-control"></div>
<input type="hidden" id="idMenu" name="idMenu" value="{{ $menu->idMenu }}">
<div class="form-group"><label>URL</label> <input type="text" id="descripcionEditar" name="descripcionEditar" placeholder="Ingrese enlace" class="form-control"></div>
<div class="form-group">
<div class="form-group">
{!! Form::file('rutaImagenSlider',['id'=>'file-rutaImagenSlider']) !!}
</div>
</div>
{!! Form::close() !!}
<div>
<button onclick="guardarSlider();" class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>REGISTRAR</strong></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
LARAVEL(REquesT)
class SliderRequest 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 [
'titulo' => 'required',
'subtitulo' => 'required',
'descripcion' => 'required'
];
}
}
答案 0 :(得分:0)
require
应为required
但是你的问题不是模态的,但你最后一行的规则是错误的。
return [
'titulo' => 'required',
'subtitulo' => 'required',
'descripcion' => 'required'
];
答案 1 :(得分:-1)
如果您发布了处理表单请求的控制器代码以及它如何与SliderRequest类集成,那将会很有帮助。