Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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
在Laravel4中使用HTML占位符_Laravel_Laravel 4_Placeholder - Fatal编程技术网

在Laravel4中使用HTML占位符

在Laravel4中使用HTML占位符,laravel,laravel-4,placeholder,Laravel,Laravel 4,Placeholder,这是我的代码,我想在文本框中添加用户名作为占位符。我已经在项目中使用了引导 我试着用这个例子 {{ Form::text('username', Input::old('username')) }} 但是它给出了一个需要删除的默认值,然后用户必须键入他的值。我想知道它在Twitter.com上的显示方式等,一旦用户输入,它就会被删除 {{ Form::text('username', 'Username', Input::old('username')) }} 这适用于Laravel 4 此

这是我的代码,我想在文本框中添加用户名作为占位符。我已经在项目中使用了引导

我试着用这个例子

{{ Form::text('username', Input::old('username')) }}
但是它给出了一个需要删除的默认值,然后用户必须键入他的值。我想知道它在Twitter.com上的显示方式等,一旦用户输入,它就会被删除

{{ Form::text('username', 'Username', Input::old('username')) }}

这适用于Laravel 4

此更新已经有一段时间了,但对于Laravel,使用前者的方法是:

{{ Form::text('username', Input::old('username'),  array('placeholder'=>'Username')) }}
{{ Form::text('username', null, array('placeholder'=>'Username' )); }}
lang文件名为langfile.php,数组包含:

Former::text('field')->placeholder('langfile.path.to.placeholder.text')))

如果有人想知道密码字段应该如何工作:

<?php

    return array (  
        'path.to.placeholder.text' => 'Some Placeholder Text.'
    );
使用:


+1对于Input::old(),直到现在才知道。这实际上是一个可行的答案,因为它用简短的代码删除并替换了不必要的参数。这应该是正确的答案,因为该问题仅要求使用laravel 4添加placeholds以形成元素的方法。我重复一遍,这是您可能想要使用的密码字段的正确答案。{code>{{Form::password('field-name',array('placeholder'=>'placeholder text','class'=>'classname')}}
希望有帮助!
{{ Form::password('password',  array('placeholder'=>'Password')) }}
{{ Form::text('txtUsername', '',array('class'=>'input', 'placeholder'=>'Username')) }}