def get_field_prefix(form, field_name, value):
    """
    Return the field prefix for the matching 'field_name' and 'value'.

    :param form:       a webtest.forms.Form instance
    :param field_name: a string
    :param value:      a string
    """
    field = next(
        (field for field in form.fields
         if (field is not None) and (field_name in field) and (form[field].value == value)), None)

    return '-'.join(field.split('-')[:2]) if field else None