使用Laravel Form类为某些选项添加'disabled'属性 [英] Using Laravel Form class to add the 'disabled' attribute for some options

查看:353
本文介绍了使用Laravel Form类为某些选项添加'disabled'属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Laravel 4的Form类,我有以下列表:

Using Laravel 4's Form class, I have this list:

{{ Form::select('set', $sets, $prod->set_id, array('class' => 'form-select')) }}

如何添加仅对某些选项禁用的属性?

How can I add the attribute disabled only for some options?

推荐答案

尝试一下;

{{ Form::select('set', $sets, $prod->set_id, array('class' => 'form-select', 'disabled')) }}

您传递的最后一个参数将最终是HTML属性.而且您不能仅将其限制为某些选项.您只能禁用输入字段.如果您不希望某些选项在传递给视图之前从$ set变量中忽略它们.

The last parameter you pass will end up being the HTML attributes. And you cannot restrict it for only some options. You can only disable the input field. If you don't want certain options omit them from your $set variable before passing to the view.

这篇关于使用Laravel Form类为某些选项添加'disabled'属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆