You also have another better option of using generic service to set the UI attributes. However this may not work in all cases especially when you have list in your form.
Refer blogs by Raja Sekhar Kuncham :
FPM Forms Scripting (Continued)...
Hope this helps.
Regards,
Sahir.