3
votes

I have created some fields in drupal 7 in create user administration. I want those fields in my custom form in my custom module in drupal 7.

I am not sure but this function attach_field_load() will do the trick. If someone can help.

Regards

2

2 Answers

2
votes

There is no attach_field_load() function to the best of my knowledge, you're probably looking for field_attach_form():

function MYMODULE_my_form($form, &$form_state, $node) {
  field_attach_form('node', $node, $form, $form_state);
}
2
votes

As of Drupal 7.22 you can simply use the following code to add a single field to your form.

field_attach_form('my_entity_type', $entity, $form, $form_state, NULL, array('field_name' => 'field_myfield'));

See https://drupal.org/node/1825844