imehesz
(Imehesz)
July 27, 2009, 12:47pm
1
hello everyone,
I have a FORM and some dropdown fields in it. How can I disable them or set them ReadOnly?
$options['readonly']=true; // this works only with regular text fields!
works fine with regular text fields , but not with dropdowns , because the $options array there sets the dropdown options, not the actual form field options )
thanks,
–iM
bruno
(bruno_)
July 27, 2009, 1:14pm
2
Hi,
[font=“Courier New”]<select>[/font] and [font=“Courier New”]<option>[/font] don’t have [font=“Courier New”]readonly[/font] attribute. Only [font=“Courier New”]<input>[/font] and [font=“Courier New”]<textarea>[/font] can have this attribute.
To disable a [font="Courier New"]DropDownList[/font] juste write :
array('disabled'=>'true')
in [font="Courier New"]htmlOptions[/font].
imehesz
(Imehesz)
July 27, 2009, 2:23pm
3
Hi,
[font=“Courier New”]<select>[/font] and [font=“Courier New”]<option>[/font] don’t have [font=“Courier New”]readonly[/font] attribute. Only [font=“Courier New”]<input>[/font] and [font=“Courier New”]<textarea>[/font] can have this attribute.
To disable a [font="Courier New"]DropDownList[/font] juste write :
array('disabled'=>'true')
in [font="Courier New"]htmlOptions[/font].
thanks, [bruno_] that did the trick
–iM
Hi
i have a problem
i put disable="false" or readonly="false" but the field is always disabled o r readonly
exists any way do it is?
imehesz
(Imehesz)
October 1, 2009, 2:04pm
5
hello Horacio,
just don’t set it at all. It defaults to false anyway.
–iM
hi
mi code is
<div class="simple">
<?php $tipo_documento=Varios::cargarDominio('TIPO_DOCUMENTO'); ?>
<?php echo CHtml::activeLabelEx($model,'tipo_documento'); ?>
<?php echo CHtml::activeDropDownList($model, 'tipo_documento', CHtml::listData($tipo_documento, 'valor', 'descripcion')
,array( 'prompt'=>'Seleccione...','readonly'=>Seguridad::noTieneRolChar('PER_INGRESO'))); ?>
</div><div class="simple">
<?php echo CHtml::activeLabelEx($model,'nro_documento'); ?>
<?php echo CHtml::activeTextField($model,'nro_documento',array('readonly'=>Seguridad::noTieneRolChar('PER_INGRESO'))); ?>
</div>
Seguridad::noTieneRolChar return true or false
cyberpol
(Cyberpol 777)
October 1, 2009, 2:11pm
7
use
‘disabled’=>Seguridad::noTieneRolChar(‘PER_INGRESO’)
instead of
‘readonly’=>Seguridad::noTieneRolChar(‘PER_INGRESO’)
Ismael
(Shalanga)
October 1, 2009, 2:14pm
8
[color="#0000FF "]disabled="disabled"[/color]
[color="#FF0000 "]disable="false"[/color]
no, not work
is it the solution?
<?php
if (Seguridad::tieneRol('PER_INGRESO'))
echo CHtml::activeDropDownList($model, 'tipo_documento', CHtml::listData($tipo_documento, 'valor', 'descripcion')
,array( 'prompt'=>'Seleccione...'));
else
echo CHtml::activeDropDownList($model, 'tipo_documento', CHtml::listData($tipo_documento, 'valor', 'descripcion')
,array( 'prompt'=>'Seleccione...','disabled'=>'true'));
?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'nro_documento'); ?>
<?php
if (Seguridad::tieneRol('PER_INGRESO'))
echo CHtml::activeTextField($model,'nro_documento');
else
echo CHtml::activeTextField($model,'nro_documento',array('readonly'=>'true'));
?>
</div>
cyberpol
(Cyberpol 777)
October 1, 2009, 2:40pm
10
did you try this
<?php
if (Seguridad::tieneRol('PER_INGRESO'))
echo CHtml::activeDropDownList($model, 'tipo_documento', CHtml::listData($tipo_documento, 'valor', 'descripcion')
,array( 'prompt'=>'Seleccione...'));
else
echo CHtml::activeDropDownList($model, 'tipo_documento', CHtml::listData($tipo_documento, 'valor', 'descripcion')
,array( 'prompt'=>'Seleccione...','disabled'=>'true'));
?>
if this works, why no make
Seguridad::tieneRol(‘PER_INGRESO’) returns a string (‘true’ or ‘false’) instead of a boolean (true or false)?
THE FINAL APROACH
<?php
if (!Seguridad::tieneRol('PER_INGRESO')) {
$readonly=array() ;
$disabled=array() ;
}
else {
$readonly=array('readonly'=>'readonly') ;
$disabled=array('disabled'=>'disabled') ;
}
?>
<div class="simple">
<?php $tipo_documento=Varios::cargarDominio('TIPO_DOCUMENTO'); ?>
<?php echo CHtml::activeLabelEx($model,'tipo_documento'); ?>
<?php
echo CHtml::activeDropDownList($model, 'tipo_documento', CHtml::listData($tipo_documento, 'valor', 'descripcion')
,array_merge($disabled,array( 'prompt'=>'Seleccione...')));
?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'nro_documento'); ?>
<?php
echo CHtml::activeTextField($model,'nro_documento',$readonly);
?>
</div>
kalyon
(Hkalyoncu)
October 1, 2009, 2:58pm
12
u can say:
$readonly = array(‘readOnly’=>true);
did you try this
if this works, why no make
Seguridad::tieneRol(‘PER_INGRESO’) returns a string (‘true’ or ‘false’) instead of a boolean (true or false)?
tieneRol return boolean
noTieneRolChar return char