I am using field_info_instances() function to get all the fields of a content type and display it in a csv file.

but the problem is I can't change the order of the fields return by this function.

Any one who know how to change the order of the fields?

  • 1
    It's just an array, you can re-order it however you see fit with sort() or one of its sibling functions. I'm not sure how this relates to Drupal exactly, it seems to be a basic PHP question? Apologies if I've got that wrong, but if so perhaps you could clarify the Drupal part of this (bearing in mind field_info_instances() takes no parameters that can be used for ordering)? – Clive Mar 13 '14 at 11:03
  • Can you tell me what order this function follow? Means in which order it display the fields. it is taking the order from the weights in the manage fields or the field's creation date? – Ahmad Mar 13 '14 at 11:14
  • There's no explicit ordering (see field_read_fields(), that's where the query gets run), so it's whatever your DB's default ordering is – Clive Mar 13 '14 at 11:16

Browse other questions tagged or ask your own question.