How to set form input required attribute in laravel 4

前端 未结 4 464
天命终不由人
天命终不由人 2021-01-03 23:05

I\'m using the laravel framework for a project, and I\'m implementing a basic form page, where I require certain values to be required, something that can be do

4条回答
  •  鱼传尺愫
    2021-01-03 23:46

    Since simply writing ['required'] did not work, I searched online a bit more and found the answer, so I thought I'd share it here.

    The third parameter is an array of optional attributes, which, in convention, must be written as:

    {{ Form::text('abc','',array('required' => 'required')) }}
    

    Similarly, for a radio button with default selected/checked we have:

    {{ Form::radio('abc', 'yes', array('checked' => 'checked')) }}
    

提交回复
热议问题