【问题标题】:Codeigniter failed set rows and rows textareaCodeigniter 设置行和行 textarea 失败
【发布时间】:2016-02-16 16:03:48
【问题描述】:

我的视图文件:

echo form_textarea('',$data['note_order'],"rows='4' cols='50'");

但是我在浏览器中得到了什么:

<textarea name="" cols="90" rows="12">Blablablabla</textarea>

如果我更改视图代码,例如:

$options = array(
    'rows' => 4,
    'cols' => 50
);
echo form_textarea('',$data['note_order'],$options);

我收到错误:

A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: helpers/form_helper.php
Line Number: 265

为什么我的设置不工作?

【问题讨论】:

    标签: php codeigniter textarea


    【解决方案1】:

    试试这个

    $options = array(
        'name' => '',
        'rows' => '4',
        'cols' => '50',
        'value'=> $data['note_order']
    );
    echo form_textarea($options);
    

    【讨论】:

      【解决方案2】:

      我找到了

      echo form_textarea('notes', set_value('notes'), array('rows' => '3'));
      

      导致标记为 rows="10";不是我想要的。而

      echo form_textarea(array(
              'name' => 'notes',
              'id' => 'notes',
              'value' => set_value('notes'),
              'rows' => '3'
          ));
      

      (带有或不带有 id 元素)正确地生成带有 rows="3" 的标记。

      【讨论】:

        【解决方案3】:

        转到 system/helpers/form_helper 然后查找 form_textarea 然后注释掉

        $defaults = array(
        			'name' => is_array($data) ? '' : $data,
        			// 'cols' => '40', --> this
        			// 'rows' => '10' --> this
        		);

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-12-27
          • 1970-01-01
          • 1970-01-01
          • 2012-11-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多