Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向Laravel 4中的表单添加类/ID_Php_Laravel_Laravel 4 - Fatal编程技术网

Php 向Laravel 4中的表单添加类/ID

Php 向Laravel 4中的表单添加类/ID,php,laravel,laravel-4,Php,Laravel,Laravel 4,我正在尝试向Laravel4中表单的特定元素添加类和ID。例如,我希望: <textarea type="text" id="description" onfocus="this.value=''; setbg('#f0f7f8');" onblur="setbg('white')" name="description" value="" rows="10"></textarea> Form::textarea('description', null, array(

我正在尝试向Laravel4中表单的特定元素添加类和ID。例如,我希望:

<textarea type="text" id="description" onfocus="this.value=''; setbg('#f0f7f8');" onblur="setbg('white')" name="description" value="" rows="10"></textarea>
Form::textarea('description', null, array(
    'id'      => 'description',
    'rows'    => 10,
    'onFocus' => 'this.value=\'\'; setbg(\'#f0f7f8\');'
));

我在文档中没有看到这一点。谢谢大家!

Form::textarea
方法使用第三个参数,传递键值数组。例:

Form::textarea('description', null, [
    'id'      => 'description',
    'rows'    => 10,
]);

虽然这是一个老问题,但我只想说,您可以像这样避开javascript:

<textarea type="text" id="description" onfocus="this.value=''; setbg('#f0f7f8');" onblur="setbg('white')" name="description" value="" rows="10"></textarea>
Form::textarea('description', null, array(
    'id'      => 'description',
    'rows'    => 10,
    'onFocus' => 'this.value=\'\'; setbg(\'#f0f7f8\');'
));

就是这样:)

然而,当我这样做的时候,焦点发生了一些事情。输出:文本框没有以我休息时想要的颜色显示。哦,它似乎在逃避值。在这种情况下,这将是一个相当麻烦的问题,因为我们必须创建新类,扩展
HtmlBuilder
,覆盖
attributeElement
方法,并使其不调用
e
方法,而这正是有效逃避内容的方法,最后将我们的新类注册为应用程序的
html
组件。除了让人讨厌之外,它还很糟糕,因为它禁用了所有HTML功能的转义。。。老实说,你真的应该在页面的末尾通过JavaScript设置你的事件。。。