Reputation: 1538
Can anyone help me figure out how can i create a widget(Field API) which will contain an image(i want to to be an ImageField) and a textarea in Drupal 7? Unfortunately i cannot find any tutorial how to do this on google. Thanks!
Upvotes: 3
Views: 7612
Reputation: 1328
Try taking a look at this tutorial. Most other ones the writer concentrates on sounding clever, this one has screenshots and is very clear and concise.
Upvotes: 0
Reputation: 1538
Sorry for not closing this. but the real answer to this is to use Field Collection module - drupal.org/project/field_collection. You add multiple field to this. When i asked this question i was new to D7 and in D6 we had to write this by hand. great module!
Upvotes: 1
Reputation: 236
you should start from this 2 hook to create the widget. then you should start creating the compound field
hook_field_widget_info() hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
here are some link to create custom field and widget http://www.phase2technology.com/node/1495/ http://drupal.org/project/dnd_character
Upvotes: 1
Reputation: 36956
There's no tutorial as such that I know of, but have a look at the Drupal Examples Module, there's a module within called field_example
with all of the info you need.
On a very basic level you want to do this:
.install
file to define what columns are going to be held in your field table (probably file ID (fid
), alternative text for the image, title text for the image and the contents of the text area in your case).Once you've jumped through all of those hoops (it doesn't actually take that long to implement, most functions are just a few lines of code), enable the module and start adding your new field to entities!
Upvotes: 7