Fixed undefined index issue in dynamic form generation