fix name attribute generation of complex models

When the model has multi levels, the replace was not working. Need to switch all . to _, not just the first.
For example: controller.formdata.field was converting to controller_formdata.field and it gave errors. Now it converts to controller_formdata_field.