Form that update fields on blur events

I am about to develop a form that needs to submit data for each field on the blur event. At which point it is validated, entered into the DB, or a validation error displayed. Whilst the ajax request is happening there needs to be a processing icon next to the field in question.

I can’t see an easy way to do this.

I could use the ajaxvalidation option, but I can’t see how to attach the processing icons. Also, there is no way to identify which field is being validated within Yii - it posts back the whole form.

I could pass the form fields back in an ajax request, but then I have to manually build the whole thing.

Am I missing something? How would you go about it?

My initial concern regarding your issue is that you want to validate a single element from a form and insert into the database. In most cases, your rules will preclude you from creating an AR record without more complete data. Does each field represent a complete AR record?

~thinkt4nk

if I can identify the field then I can write a model->update for each field. They all have defaults, so as long as that field validates it isn’t a problem*. That wouldn’t take too long to write. It is passing all the field data back and forth to JavaScript that I was wanting to avoid having to write - The validator all ready does that, if only I could attach a before and after jquery function and identify the field posted back.

Edit to add:

  • I can just create a blank model. Adjust that one field and validate.

In Yii CHtml dosen`t support jquery to change delegate(event … , couse default is delegate(‘click’ or delegate(‘change’ so i made fiew core fixes to solve this problem , so i made a core fix just type Jevent=‘blur’ in $htmlOptions if Jevent is not set it will be default set value

hire what you have to change

framework/web/helpers/CHtml.php

with attached file