Change $type to $field_type like core uses