Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 CodeIgniter:使用HTML5必需属性的输入框_Php_Codeigniter - Fatal编程技术网

Php CodeIgniter:使用HTML5必需属性的输入框

Php CodeIgniter:使用HTML5必需属性的输入框,php,codeigniter,Php,Codeigniter,我在CodeIgniter框架中有一个表单,我想使用HTML“required”属性。 我该怎么做 $data = array( 'name' => 'username', 'id' => 'username', 'value' => 'johndoe', 'maxlength' => '100',

我在CodeIgniter框架中有一个表单,我想使用HTML“required”属性。 我该怎么做

$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
            );

echo form_input($data); 
所需的结果:

    <input type="text" name="username" id="username" value="johndoe" 
required maxlength="100" size="50" style="width:50%" /> 

只需将其添加到阵列中即可

$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
              'required' => 'required'
 );

echo form_input($data); 

不太熟悉codeigniter,但您不能只做
“必需的”=>“必需的”
?请将其设置为ans。。我需要给你+1本书,就像有人已经发布了一样,没有必要复制答案:pthaanx。。它解决了。。但在过去或现在,我并没有读到“必选=必选”。我总是读“必选”。所以我问了一个问题。