Skip to content

Instantly share code, notes, and snippets.

@henrytran9x
Created December 28, 2015 08:27
Show Gist options
  • Save henrytran9x/ab36baf63106834609f6 to your computer and use it in GitHub Desktop.
Save henrytran9x/ab36baf63106834609f6 to your computer and use it in GitHub Desktop.
This module load field follow condition type field Drupal 7
<?php
public function load_fields($entity_type, $bundle_name) {
$instances = field_info_instances($entity_type, $bundle_name); // Load entity tye and bundle_name
$fields = array();
foreach($instances as $key => $instance) {
foreach($instance as $field_name => $instance_field)
{
$field_info = field_info_field($field_name);
if($field_info['type'] === 'text') { // Get Type Fields 'text' , You can conndition type other
$fields[$field_name] = $instance_field;
}
}
}
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment