0

I am using hook_form_alter and adding a extra form field to drupal node form. All works fine, but in view this field is not show up. How do i add this field?

1

Instead of adding form element using hook_form_alter use CCK field. View will not understand your custom field but a CCK fields are integrated in views.

EDIT

Please check for Tag User module.

  • But i am adding a user autocomplete or say tagging thing while adding a node. this is totally customized. So i need to add it using alter functions. – Hacker May 31 '12 at 13:12
0

To make you understand the difference between a form field and a CCK field in a Node form relationship:

Formfield

You could add a formfield to a node form, but this would only add a <input> field to your form. After adding this field, you could use Drupal's Form API (Drupal.org Form API quickstart guide) to for example validate the fields, or process them in any way you see fit. To be clear, without any validation, post-processing, etc. your field will not be used in any way.

That being said, a form field is only interesting when you make a custom module, which needs some additional information about a node which will be created / editted.

CCK field (Simply: Fields in Drupal 7)

You have numerous types of fields (eg. Text, number, references, file, etc...) which you can assign to different node types. For example, you could add a imagefield field to a node-type "Employee" to make it possible to add a picture of a employee.

I hope this clears it up a bit for you.

edit

I noticed you where trying to add a "user autocomplete" field? Try out the CCK User reference field, it's in the base module if you're using Drupal 6. If you're using Drupal 7 you'll need a separate module: References.

  • He needs solution for D6 – Shoaib Nawaz May 31 '12 at 13:41
  • 1
    I gave both, CCK for D6, Fields for D7 – Ambidex May 31 '12 at 13:42

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.