0

I have a custom module installed which displays a form at user/UID/apps/add. So, what this form does is lets user add node/nodes of "x" content type he/she wants in their app. Form is created using this function-

function devconnect_developer_apps_edit_form(array $form, array &$form_state, stdClass $account, $app_id = NULL)

I'm trying to implement this form on every node so that the user can add that particular node to an existing or a new app on a button click.

Figured out I should be passing this nodeID as a default value to the form using drupal_get_form. So created a block which renders the said form and to test if the form is being rendered I added it to a page to only see a 500 error.

Here is the block-

 <?php
    /**
     * Implements hook_block_info().
     */
    function sei_useapi_block_info() {
      $blocks = array();

      $blocks['MYBLOCK'] = array(
        'info' => t('My block'), 
        'cache' => DRUPAL_NO_CACHE,
      );
      return $blocks;
    }

    /**
     * Implements hook_block_view().
     */
    function sei_useapi_block_view($delta = '') {
      $block = array();

      switch ($delta) {
        case 'MYBLOCK':
          $block['subject'] = t('My block title');
          $block['content'] = drupal_render(drupal_get_form('devconnect_developer_apps_edit_form'));
      }
      return $block;
    }

Don't have a clue what went wrong. Any ideas? Thanks for reading !

1

The third argument to your form is $account, and it doesn't have a default argument. You aren't passing that block in your argument, which is why it is crashing.

0

Rightly pointed, Thanks

For any other noobs like me out there-

'page arguments' => array('devconnect_developer_apps_edit_form', $user, NULL),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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