0

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 ?

1 Answer 1

1

you have to write script for that input

 document.getElementById("name").readOnly = true;
Sign up to request clarification or add additional context in comments.

8 Comments

you mean there's no yii 1.x way to make it read only ? , so javascript is the only way?
<input id="name" name="name" type="text" value="Firstname" readonly/>
try that may be you get solution that you need i am not sure bt it might work
that's plain html...i'm using a php framework , therefore, the input form is made dynamically on the fly
then you have to define rule for required field in model as required
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.