[Solved] CCaptcha and nonobtrusive javascript or progressive enhancement


What is Yii's philosophy vis-à-vis nonobtrusive javascript or progressive enhancement?

I was initially excited that Yii was using jQuery which is designed for nonobtrusive javascript.

I was however disappointed to find in the built in captcha implementation that a link is displayed to refresh the image which requires js and does not degrade gracefully.

Would it be too much to ask to have this behavior changed in one of two ways.

  1. Have the link/button added on the fly by jQuery using [tt]$("img#yw0).after()[/tt]. This way if a user does not have js he does not see the otherwise useless link/button.

  2. This method requires the button type instead of the link. The button would submit the form with an additional variable set warning the model not to validate but to return the same form with a different captcha image. JS users would get the same functionality as now with jQuery intercepting the submit function.

The second solution is more complicated but strikes me as preferable from the user standpoint as it provides a high level of service across a wider user base. Off the top of my head the second method would require at the very least additional logic in the controller. Perhaps this could be handled by the CCaptchaAction class.



Thank you for your suggestions.

We should make the enhancement 1 only when we are able to achieve 2. However, the enhancement 2 is not easy because CCaptachAction does not have the knowledge about the form model and thus it is difficult to keep the form populated with the data user just entered. That's also why we choose to use AJAX to refresh the image.

I understand why you would be reluctant to work on 2 as it is indeed complex.

This quote has me a little surprised though.


We should make the enhancement 1 only when we are able to achieve 2.

Why not make enhancement 1 straightaway. Doesn't it bother you that at this time javascript-less users see a link labeled "Get new image" which does nothing for them and fails to explain why it doesn't work?

Thank you for pointing this out. I agree that we should implement 1. Could you please create a ticket for this? Thanks!

Ticket: http://code.google.c…s/detail?id=111

Fixed as of r582.