'Set the form field field_name to field_value if it exists, and return the provided dict containing that value. If
the field does not exist in the provided form, return a dict without that index.'

def set_form_value(self, form, kwd, field_name, field_value):

    form_id = form.attrs.get('id')
    controls = [control for control in form.controls if (str(control.name) == field_name)]
    if (len(controls) > 0):
        log.debug(('Setting    field    %s    of    form    %s    to    %s.' % (field_name, form_id, str(field_value))))
        tc.formvalue(form_id, field_name, str(field_value))
        kwd[field_name] = str(field_value)
    elif (field_name in kwd):
        log.debug('No    field    %s    in    form    %s,    discarding    from    return    value.', field_name, form_id)
        del kwd[field_name]
    return kwd
