嗨,我使用laravel开发应用程序有任何方法可以使用验证使输入日期字段大于或等于另一个日期字段.
我知道我可以通过jquery实现这一点,我已经有了这个工作,但我想知道这是否可以通过laravel验证实现,因为laravel已经有一些预定义的验证.
例如
protected $validationRules = array
(
'a' => 'date',
'b' => 'date|(some validation so that the b value is greater than or equal to that of 'a')'
);
Run Code Online (Sandbox Code Playgroud)
编辑
如果有任何其他方法使用laravel概念解决问题请告诉我
我试过了
Validator::extend('val_date', function ($attribute,$value,$parameters) {
return preg_match("between [start date] and DateAdd("d", 1, [end date])",$value);
});
Run Code Online (Sandbox Code Playgroud)
提前致谢
我有一个复选框,我想让我的复选框默认选中,如果用户取消选中复选框并保存表单,我需要在检索或编辑表单数据时取消选中该复选框。
我的查看页面
<div class="form-group {{ $errors->has('active') ? 'error' : '' }}">
<label for="active" class="col-md-3 control-label">@lang('admin/assetdetails/form.active')</label>
<div class="controls col-md-7">
{{ Form::checkbox('active', 1, Input::old('active', $assetdetail->active), array('class'=>'isnesdbox')) }}
{{ $errors->first('active', '<span class="alert-msg"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
给这个正确地从数据库中带回旧数据,但我无法将我的复选框选中为默认值
控制器:
public function postEdit($assetdetailId = null)
{
// Check if the location exists
if (is_null($assetdetail = Assetdetail::find($assetdetailId)))
{
// Redirect to the blogs management page
return Redirect::to('admin/settings/assetdetails')->with('error', Lang::get('admin/assetdetails/message.does_not_exist'));
}
// get the POST data
$new = Input::all();
// attempt validation
if ($assetdetail->validate($new))
{
// Update …
Run Code Online (Sandbox Code Playgroud)