Amit
Amit

Reputation: 73

How to disable input tag in cakephp

I want to disable input tag ,my demo code is

echo $this->Form->input('AreaMaster.GroupID', array('type'=>'select', 'div'=>'control-group', 
                    'cascadeFrom'=>'AreaMasterAreaType012',  'label'=>array('text' => 'Area Group','class'=>'control-label required'),'tabindex'=>'4', 'autoBind' => false,
                        'options'=>$dataSource, 'disabled' => 'true'));

I applied 'disabled' => 'true' but it not work . So please suggest me appropriate solution..

Upvotes: 0

Views: 5480

Answers (2)

bigmike7801
bigmike7801

Reputation: 3968

You are using 'disabled' => 'true' (notice the single quotes you have around true. This may have been the reason. I am using CakePHP 2.3 and it's working fine however.

You can also use any of the following:

'disabled'
'disabled' => 'disabled'
'disabled' => true

So your code would look like one of these:

echo $this->Form->input('AreaMaster.GroupID', array('type'=>'select', 'div'=>'control-group', 
                    'cascadeFrom'=>'AreaMasterAreaType012',  'label'=>array('text' => 'Area Group','class'=>'control-label required'),'tabindex'=>'4', 'autoBind' => false,
                        'options'=>$dataSource, 'disabled'));

echo $this->Form->input('AreaMaster.GroupID', array('type'=>'select', 'div'=>'control-group', 
                    'cascadeFrom'=>'AreaMasterAreaType012',  'label'=>array('text' => 'Area Group','class'=>'control-label required'),'tabindex'=>'4', 'autoBind' => false,
                        'options'=>$dataSource, 'disabled' => 'disabled'));

echo $this->Form->input('AreaMaster.GroupID', array('type'=>'select', 'div'=>'control-group', 
                    'cascadeFrom'=>'AreaMasterAreaType012',  'label'=>array('text' => 'Area Group','class'=>'control-label required'),'tabindex'=>'4', 'autoBind' => false,
                        'options'=>$dataSource, 'disabled' => true));                                                    

Upvotes: 3

Fazal Rasel
Fazal Rasel

Reputation: 4526

Just use 'disabled'

Like-

echo $this->Form->input('AreaMaster.GroupID', array('type'=>'select', 'div'=>'control-group', 
                    'cascadeFrom'=>'AreaMasterAreaType012',  'label'=>array('text' => 'Area Group','class'=>'control-label required'),'tabindex'=>'4', 'autoBind' => false,
                        'options'=>$dataSource, 'disabled'));

Upvotes: 0

Related Questions