Mobile-Menu iFuturz Infoweb Inc. Contact Portfolio

05

Jul

Create Custom Form as a Block in Drupal

Create Custom Form as a Block in Drupal

Posted On : July 5, 2013

| No Comment

If User make custom Module form as block in drupal so that time put below code in your Custom module-name.module file

Here Custom-Modules-Name is your Module name.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Custom-Modules-Name_block($op = 'list', $delta = 0, $edit = array()) {
 
switch ($op) {
 
case 'list':
 
$blocks[1] = array('info' => t("Custom-Modules-Name"));
 
return $blocks;
 
case 'view':
 
$block =array(
 
'subject'=>t("Custom-Modules-Name"),
 
'content'=>drupal_get_form('Custom-Modules-Name_form'));
 
return $block;
 
}
 
}

After enable your Custom module that time make a one block in site building-> block menu then configure the block title and show block in specific pages etc…

Screenshot:

Block Configuration

After block is configure then define a block in different region.

Assign a Block in Different Region

Now, you have get form as block your define specific page.

Form as a Block

  • Tags:

Comment