Stopping Form Field From Clear On Focus

When I create a CActiveForm (for User model), when going to user/update

the form textfields are cleared when I focus on them.

Can I stop this from happening with a setting somehow?

I really do not like this Drupal-like default behaviour - I’d prefer the entire textfield’s text is selected instead, that way when I type it gets replaced or i can copy it or edit it … alot more flexible.

Thanks in advance for any help!


Are you using any kind of extension? And what Yii version are you using? I’ve never seen such behavior with standard Yii apps…

Hi bennouna,

Sorry for my late reply (didn’t get the email notification for some reason?!)

Not using any kind of extensions no.

I’m using Yii version 1.1.13

That’s quite strange you’ve not seen this behavior - anyone else seen this automatic form-field clearing thing?

I’ve disabled ajax-validation for the form (in both the controller and the form in the view); I’ve disabled all my Firefox add-ons (safe mode) - I’ve also checked the page for any Jquery / css that might be causing this - can’t see it anywhere … still this is happening (in both Firefox and Chrome, which lets me think it’s not a browser issue?)

Really stumped!


No, the framework doesn’t do that by default. It sounds like you have a piece of global javascript that’s gone awry. Are you using javascript to automatically clear a search field on focus or something?

Hmmm, my bad guys! There WAS a piece of JS which was clearing fields:

(I’ve changed these values to false now, and all is good).

function initInputs() {


		// filter options

		clearInputs: false,

		clearTextareas: false,

		clearPasswords: false,

		skipClass: 'default',


		// input options

		wrapWithElement: false,

		showUntilTyping: false,

		getParentByClass: false,

		placeholderAttr: 'value'



This code was inserted by guys who cut up the design into markup. I should probably look at removing it :slight_smile:

Sorry for the schoolboy error!