CodeIgniter: form_input as readonly

11,757

Solution 1

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

This will do your work! Good Luck!

Solution 2

Try as below :

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

Solution 3

Add 'readonly' => 'readonly' to make it read only

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

Read CodeIgniter Form Helper

Share:
11,757
Liam Fell
Author by

Liam Fell

Updated on November 29, 2022

Comments

  • Liam Fell
    Liam Fell over 1 year

    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