CodeIgniter: form_input as readonly

时间:2016-01-12 11:22:43

标签: php codeigniter

I have the following form input:

<?php echo form_input(array('name'=>'stockist['.$stockist->ID.'][ID]','value'=>form_decode($stockist->ID), 'class'=>'span1'));?>

I'd like to make this a read-only field, however any attempt to make this read=only using HTML syntax throws an error. Does anyone know if it's possible to make a form_input type read only?

Thanks

3 个答案:

答案 0 :(得分:3)

<?php echo form_input(array('name'=>'stockist['.$stockist->ID.'][ID]','value'=>form_decode($stockist->ID), 'class'=>'span1','readonly'=>'true'));?>

这将完成你的工作!祝你好运!

答案 1 :(得分:1)

尝试如下:

$data_name = array(
'name' => 'emp_name',
'id' => 'emp_name_id',
'value' => 'John'
'readonly' => 'readonly'
);
echo form_input($data_name);

答案 2 :(得分:1)

添加'readonly' => 'readonly'以使其成为只读

 <?php echo form_input(
        array('name' => "stockist['.$stockist->ID.'][ID]",
    'value' => form_decode($stockist->ID),
    'class' => 'span1', 
    'readonly' => 'readonly')); ?>

阅读CodeIgniter Form Helper