PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 16, 2022

[FIXED] how to set widget form in to read only or disable it in yii version 1.x?

 February 16, 2022     yii     No comments   

Issue

I have this piece of code in my view file

            <div>
                <div class="column span-4"><?php echo $form->labelEx($model, "name"); ?></div>
                <div class="column span-flexible">
                    <?php echo $this->module->createWidget($form, $model,"name"); ?>
                    <ul class="errorlist"><li><?php echo $form->error($model, "name"); ?></li></ul>
                </div>
            </div>

how to make it as read only? or disable it? I have tried already these methods

<?php echo $this->module->createWidget($form, $model,"name",array('htmlOptions' => array('readonly'=>'readonly')); ?>

OR

<?php echo $this->module->createWidget($form, $model,"name",array('htmlOptions'=>array('readOnly' => 'readOnly')); ?>

OR

<?php echo $this->module->createWidget($form, $model,"name",array('htmlOptions'=>array('readonly'=>true)); ?>

None of those worked. what's the solution to fix this in order to make it as read only ?


Solution

you have to write script for that input

 document.getElementById("name").readOnly = true;


Answered By - Jenish
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing