Use the passed value of the field instead of getting it from $field, since this doesn't work right with repeaters.