| 1 |
Views Embed Form
|
| 2 |
================
|
| 3 |
|
| 4 |
Version
|
| 5 |
=======
|
| 6 |
Compatible with 6.x version of Drupal core
|
| 7 |
|
| 8 |
Author
|
| 9 |
======
|
| 10 |
Jakub Suchy, <info at jsuchy dotNOSPAM cz>
|
| 11 |
|
| 12 |
Examples
|
| 13 |
========
|
| 14 |
|
| 15 |
Every module developer who would like to embed his form in view needs to
|
| 16 |
create function called MODULENAME_views_embed_form(). Example:
|
| 17 |
|
| 18 |
function testmodule_views_embed_form() {
|
| 19 |
return array(
|
| 20 |
// Key in this array is the name of a form and also the name of a form function.
|
| 21 |
'testmodule_form' => t('Form for testing module'),
|
| 22 |
// Value in this array is a human-readable name of the form, use t() to allow internationalization.
|
| 23 |
'testmodule_basket_form' => t('Add to basket form'),
|
| 24 |
);
|
| 25 |
}
|
| 26 |
|
| 27 |
Then edit a view, add a field in group Embedded and select your form name.
|
| 28 |
Everytime a view is displayed, your form is called for every view row. Row
|
| 29 |
fields (including node nid) are passed as an argument to the form. Example:
|
| 30 |
|
| 31 |
function testmodule_form(&$form_state, $fields) {
|
| 32 |
// $fields are from a view, useful when you need to know node id for this row.
|
| 33 |
// It should be $fields->nid.
|
| 34 |
}
|