1

I have a module, and I would like its add form to be put into a block. So my question is, how would you take a modules page (admin/build/mymodule/add) and give it a block? So this module will now have its own block in the blocks admin page. Do you do this by its url, by module, or by form id?

1
  • you want your module to have its own admin config page?
    – saadlulu
    Commented May 22, 2013 at 12:40

2 Answers 2

2

You can do this with the $form_id and the function drupal_get_form();

You need to create a module and use hook_block():

function mysecondmodule_block($op = 'list', $delta = 0, $edit = array()) {
  switch($op) {
    case 'list':
      return array(array('info' => 'mymodule add block'));
    break;
    case 'view':
      if($delta == 0) {
        return array(
         'subject' => 'Mymodule Add',
         'content' => drupal_get_form('form-id');
        );
      }
    break;
  }
}
0
function mysecondmodule_block($op='list',$delta=0,$edit=array()){
  switch($op) {
    case 'list':
       return array(array('info'=>'mymodule add block'));
       break;
    case'view';
       if($delta==0){
         return array(
          'subject'=>'Mymodule Add',
          'content'=> drupal_get_form('form-id');
           );
       }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.