def set_form_fields(self, form_field_dict, parent_key=None, field_type=None):
for form_key, field_value in form_field_dict.items():<EOL><INDENT>form_key = make_key(parent_key, form_key) if parent_key is not None else form_key<EOL>if isinstance(field_value, tuple):<EOL><INDENT>set_list_class = False<EOL>base_key = form_key<EOL>if ListField in (field_value.field_type, field_type):<EOL><INDENT>if parent_key is None or ListField == field_value.field_type:<EOL><INDENT>if field_type != EmbeddedDocumentField:<EOL><INDENT>field_value.widget.attrs['<STR_LIT:class>'] += '<STR_LIT>'.format(form_key)<EOL><DEDENT>set_list_class = True<EOL><DEDENT>else:<EOL><INDENT>field_value.widget.attrs['<STR_LIT:class>'] += '<STR_LIT>'<EOL><DEDENT>list_keys = [field_key for field_key in self.form.fields.keys()<EOL>if has_digit(field_key)]<EOL>key_int = <NUM_LIT:0><EOL>while form_key in list_keys:<EOL><INDENT>key_int += <NUM_LIT:1><EOL><DEDENT>form_key = make_key(form_key, key_int)<EOL><DEDENT>if parent_key is not None:<EOL><INDENT>valid_base_keys = [model_key for model_key in self.model_map_dict.keys()<EOL>if not model_key.startswith("<STR_LIT:_>")]<EOL>while base_key not in valid_base_keys and base_key:<EOL><INDENT>base_key = make_key(base_key, exclude_last_string=True)<EOL><DEDENT>embedded_key_class = None<EOL>if set_list_class:<EOL><INDENT>field_value.widget.attrs['<STR_LIT:class>'] += "<STR_LIT>".format(base_key)<EOL>embedded_key_class = make_key(field_key, exclude_last_string=True)<EOL><DEDENT>field_value.widget.attrs['<STR_LIT:class>'] += "<STR_LIT>"<EOL>if base_key == parent_key:<EOL><INDENT>field_value.widget.attrs['<STR_LIT:class>'] += '<STR_LIT>'.format(base_key)<EOL><DEDENT>else:<EOL><INDENT>field_value.widget.attrs['<STR_LIT:class>'] += '<STR_LIT>'.format(base_key, parent_key)<EOL><DEDENT>if embedded_key_class is not None:<EOL><INDENT>field_value.widget.attrs['<STR_LIT:class>'] += '<STR_LIT>'.format(embedded_key_class)<EOL><DEDENT><DEDENT>default_value = self.get_field_value(form_key)<EOL>if isinstance(default_value, list) and len(default_value) > <NUM_LIT:0>:<EOL><INDENT>key_index = int(form_key.split("<STR_LIT:_>")[-<NUM_LIT:1>])<EOL>new_base_key = make_key(form_key, exclude_last_string=True)<EOL>for list_value in default_value:<EOL><INDENT>list_widget = deepcopy(field_value.widget)<EOL>new_key = make_key(new_base_key, six.text_type(key_index))<EOL>list_widget.attrs['<STR_LIT:class>'] += "<STR_LIT>".format(make_key(base_key, key_index))<EOL>self.set_form_field(list_widget, field_value.document_field, new_key, list_value)<EOL>key_index += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.set_form_field(field_value.widget, field_value.document_field,<EOL>form_key, default_value)<EOL><DEDENT><DEDENT>elif isinstance(field_value, dict):<EOL><INDENT>self.set_form_fields(field_value, form_key, field_value.get("<STR_LIT>", None))<EOL><DEDENT><DEDENT>
Set the form fields for every key in the form_field_dict.

Params:
  form_field_dict -- a dictionary created by get_form_field_dict
  parent_key -- the key for the previous key in the recursive call
  field_type -- used to determine what kind of field we are setting