Hi,
Hopefully this is a tired old question and someone replies with the answer.
I have created all my forms but now want to put them into the site. I am struggling to understand how to make these components which can be added to a page. I imagined they could have been added as blocks but there is no option to do so. Currently downloading formblock module hoping this will solve my problem.
Please advise if this is an appropriate approach.
Iain
"Created all my forms..." How did you create them? If they are in a module, why not add a simple hook_block() [or the D7 equivalents]? It looks like the formblock module probably does that with some fancy wrapping stuff.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Iain Wiseman
I have created all my forms but now want to put them into the site. I am struggling to understand how to make these components which can be added to a page. I imagined they could have been added as blocks but there is no option to do so. Currently downloading formblock module hoping this will solve my problem.
Please advise if this is an appropriate approach.
On 6/10/2011 2:28 a.m., Ms. Nancy Wichmann wrote:
"Created all my forms..." How did you create them? If they are in a module, why not add a simple hook_block() [or the D7 equivalents]? It looks like the formblock module probably does that with some fancy wrapping stuff. /*Nancy*/ Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
Thanks Nancy,
They are in a module. I googled for some time and came across
http://stackoverflow.com/questions/1450941/inserting-a-form-into-a-block-in-...
Which suggested
function yourmodule_block_view($delta='') { switch($delta) { case 'your_block_name': $block['subject'] = null; // Most forms don't have a subject $block['content'] = drupal_get_form('yourmodule_form_function'); break; } return $block; }
However I have done that for one of my simple forms and cannot see it appear under block.
Assume I am an idiot when replying because it might be me being really silly. :-)
Thanks as always for your help. I have come a long way over the last six months thanks to the support of this forum.
Iain
I believe the Example module includes a complete example of the block stuff. You will also need hook_block_info() (http://api.drupal.org/api/drupal/modules--block--block.api.php/function/hook... order for the blocks to show up in the blocks list. Then your hook_block_view() (http://api.drupal.org/api/drupal/modules--block--block.api.php/function/hook...) will work to generate it.
You might also be interested in http://drupal.org/coding-standards Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Iain William Wiseman iwiseman@bibble.co.nz To: support@drupal.org Sent: Wednesday, October 5, 2011 3:51 PM Subject: Re: [support] Forms in blocks
On 6/10/2011 2:28 a.m., Ms. Nancy Wichmann wrote: "Created all my forms..." How did you create them? If they are in a module, why not add a simple hook_block() [or the D7 equivalents]? It looks like the formblock module probably does that with some fancy wrapping stuff.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
Thanks Nancy,
They are in a module. I googled for some time and came across
http://stackoverflow.com/questions/1450941/inserting-a-form-into-a-block-in-...
Which suggested
function yourmodule_block_view($delta='') { switch($delta) { case 'your_block_name': $block['subject'] = null; // Most forms don't have a subject $block['content'] =
drupal_get_form('yourmodule_form_function');
break; } return $block; }
However I have done that for one of my simple forms and cannot see
it appear under block.
Assume I am an idiot when replying because it might be me being
really silly. :-)
Thanks as always for your help. I have come a long way over the last
six months thanks to the support of this forum.
Iain
-- [ Drupal support list | http://lists.drupal.org/ ]
On 06/10/11 10:56, Ms. Nancy Wichmann wrote:
I believe the Example module includes a complete example of the block stuff. You will also need hook_block_info() (http://api.drupal.org/api/drupal/modules--block--block.api.php/function/hook...) in order for the blocks to show up in the blocks list. Then your hook_block_view() (http://api.drupal.org/api/drupal/modules--block--block.api.php/function/hook...) will work to generate it.
You might also be interested in http://drupal.org/coding-standards /*Nancy*/
Thanks Nancy easy when you know how. This worked perfectly.
You do a great service to people on this forum
Iain