CHtml::activeTextField

Can i put a where condition in an CHtml::activeTextField??

I need the value of a textfield is equal to another previously inserted

The description you give does not help.

inserted ???

You have inserted the value in the database or there is an other textfield above?

So I’ll explain… a have a field in a db table which is foreign key linked to another field in another table … I should connect these two fields and I want to add a where clause that put the two fields are the same … .

Why don’t you use a dropdownlist instead of a second textfield? Giving the user the ability to select only from the field that exist?

The ideas of tydeas_dr is good.

If you want to validate a text field in order to allow only data that there are in a table you can use a CExistValidator.

You can also use a dropDownList like that:




CHtml::activeDropDownList($model,$attribute,

	CHtml::listData(foreign_table::model()->findAll(),

	'primary_key_field','recordDescription'),

	$htmlOption);



Maybe I have not explained well … I need to pass the value of a field is a ANAGRA_ID is a code … … and then the field should also make it hidden.

I created a single form with three different models there is a field ANAGRA_ANAGRA_ID that is not nullable foreign key in another table that has a field ANAGRA_ID.Now I need these two fields have the same value and that is not visible on the form…can you help me???

how to put condition in text field?

You can do,with compare rule in model.compare your field with other,in your model.It will be like logic of confirm password.

array(‘retype_pass’, ‘compare’,‘compareAttribute’=>‘password’),