How to set form input required attribute in laravel 4

前端 未结 4 503
天命终不由人
天命终不由人 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:57

    I believe the correct answer is similar to the other post where the third parameter is

    array('required' => 'required')
    

    however to get the attribute without any value you can do the following:

    array('required' => '')
    

    The input field (for text example), will then look what was necessary in the question.

    Laravel Example:

    {{ Form::text('title', '', array('tabindex' => '1', 'required' => '')) }}
    

    HTML output:

    
    

    I believe this actually shorthand for required='', just wanted to add this note

提交回复
热议问题