0

I got the all node type list in a variable using get_node_type_info() and now am passing this variable to field_info_instances as:

array_keys(field_info_instances("node", $op_keys));

ps: $op_keys is the variable to get node types. But this is giving me list of node_type "keys" and I want field "keys".

Either tell:

(1)how to pass list of all node types as a $bundle_name in field_info_instances() ?

or

(2) when selecting any of the node_type (as an option of select list) from select list, it's corresponding field's name will get rendered. I mean to say for example: node_type = "Article" and its field names = "body", "title", "image". when "article" got clicked from select list, "body", "title", "image" should get rendered.

0

Try field_read_fields you should be able to request keys as a parameter in argument 1. And then for the conditions in argument 2 limit the fields returned by the inquiry by supplying entity and bundle keys to limit how many fields you get back. You may get back the fields used in the bundle -- but it should include the keys value.

1

To get a list of field names for each content type,, stored in a variable "list", given an array of bundle names, you could do: $list = array(); foreach($bundle_names as $bundle){ $list[$bundle] = array_keys(field_info_instances('node', $bundle)); } Hope that helps.

  • it is giving me only only first name of field on every select. not working – Sugandh Khanna Jul 14 '15 at 14:49
  • Not sure I understand. What does "first name of field" mean? It gives you a list of machine names for each field, keyed by the bundle name for each content type – Ollie Jul 14 '15 at 14:51
  • 1
    @SuagndhKhanna This is the correct solution to (1) in the original post. You can't pass multiple bundle names to field_info_instances. You can only pass 1. Therefore you loop through your bundles like Ollie showed you how to. – Beebee Jul 14 '15 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.