Skip to main content

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button. Here
Here is my code: function edit_node_block_info(){ $blocks['edit_node'] = array( 'info' => t('Custom Block to allow edit/delete/copy'), 'status' => 1, 'region' => 'Primary', 'weight' => 0, 'visibility' => BLOCK_VISIBILITY_LISTED, );

return $blocks;

} /*

  • Implements hook_block_view: sets how the block is displayed / function edit_node_block_view($delta = ''){ switch ($delta) { case 'edit_node' : $block['subject'] = t('Edit Nodes'); $block['content'] = drupal_get_form('edit_node_form'); break; } return $block; } /
  • implements custom form/creating custom form for drupal_get_form named above. */

function edit_node_form($form, &$form_state) { $form['node-id'] = array( '#type' => 'textfield', '#title' => t('Enter the Node ID'), '#max-length' => 8, '#required' => 1, ); $form['edit-node'] = array( '#type' => 'radios', '#title' => t('Select Action'), '#options' => array(t('edit'), t('delete')), '#required' => 1, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }

function edit_node_form_validate($form, &$form_state){ $query = db_query('SELECT nid FROM {node}'); foreach ($query as $result) { if (!($form_state['values']['node-id'] != $result)) { form_set_error('node-id', 'Node-id must match a current nid.'); } } }

function edit_node_submit($form, &$form_state){ if (form_state['values']['edit-node'] == 'edit'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit'; } if (form_state['values']['edit-node'] == 'delete'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete'; } }  

In the $form array do I need some sort of redirect handler to make it work?Or a print_r or render?

function edit_node_block_info(){
    $blocks['edit_node'] = array(
        'info' => t('Custom Block to allow edit/delete/copy'),
        'status' => 1,
        'region' => 'Primary',
        'weight' => 0,
        'visibility' => BLOCK_VISIBILITY_LISTED,
    );

    return $blocks;
}
/*
 * Implements hook_block_view: sets how the block is displayed
 */
function edit_node_block_view($delta = ''){
    switch ($delta) {
        case 'edit_node' :
            $block['subject'] = t('Edit Nodes');
            $block['content'] = drupal_get_form('edit_node_form');
            break;
    }
    return $block;
}
/*
 * implements custom form/creating custom form for drupal_get_form named above.
 */

function edit_node_form($form, &$form_state) {
    $form['node-id'] = array(
        '#type' => 'textfield',
        '#title' => t('Enter the Node ID'),
        '#max-length' => 8,
        '#required' => 1,
    );
    $form['edit-node'] = array(
        '#type' => 'radios',
        '#title' => t('Select Action'),
        '#options' => array(t('edit'), t('delete')),
        '#required' => 1,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

function edit_node_form_validate($form, &$form_state){
    $query = db_query('SELECT nid FROM {node}');
    foreach ($query as $result) {
        if (!($form_state['values']['node-id'] != $result)) {
            form_set_error('node-id', 'Node-id must match a current nid.');
        }
    }
}

function edit_node_submit($form, &$form_state){
    if (form_state['values']['edit-node'] == 'edit'){
        $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit';
    }
    if (form_state['values']['edit-node'] == 'delete'){
        $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete';
    }
}

In the $form array do I need some sort of redirect handler to make it work? Or a print_r or render?

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button. Here is my code: function edit_node_block_info(){ $blocks['edit_node'] = array( 'info' => t('Custom Block to allow edit/delete/copy'), 'status' => 1, 'region' => 'Primary', 'weight' => 0, 'visibility' => BLOCK_VISIBILITY_LISTED, );

return $blocks;

} /*

  • Implements hook_block_view: sets how the block is displayed / function edit_node_block_view($delta = ''){ switch ($delta) { case 'edit_node' : $block['subject'] = t('Edit Nodes'); $block['content'] = drupal_get_form('edit_node_form'); break; } return $block; } /
  • implements custom form/creating custom form for drupal_get_form named above. */

function edit_node_form($form, &$form_state) { $form['node-id'] = array( '#type' => 'textfield', '#title' => t('Enter the Node ID'), '#max-length' => 8, '#required' => 1, ); $form['edit-node'] = array( '#type' => 'radios', '#title' => t('Select Action'), '#options' => array(t('edit'), t('delete')), '#required' => 1, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }

function edit_node_form_validate($form, &$form_state){ $query = db_query('SELECT nid FROM {node}'); foreach ($query as $result) { if (!($form_state['values']['node-id'] != $result)) { form_set_error('node-id', 'Node-id must match a current nid.'); } } }

function edit_node_submit($form, &$form_state){ if (form_state['values']['edit-node'] == 'edit'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit'; } if (form_state['values']['edit-node'] == 'delete'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete'; } } In the $form array do I need some sort of redirect handler to make it work?Or a print_r or render?

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button.
Here is my code: 

function edit_node_block_info(){
    $blocks['edit_node'] = array(
        'info' => t('Custom Block to allow edit/delete/copy'),
        'status' => 1,
        'region' => 'Primary',
        'weight' => 0,
        'visibility' => BLOCK_VISIBILITY_LISTED,
    );

    return $blocks;
}
/*
 * Implements hook_block_view: sets how the block is displayed
 */
function edit_node_block_view($delta = ''){
    switch ($delta) {
        case 'edit_node' :
            $block['subject'] = t('Edit Nodes');
            $block['content'] = drupal_get_form('edit_node_form');
            break;
    }
    return $block;
}
/*
 * implements custom form/creating custom form for drupal_get_form named above.
 */

function edit_node_form($form, &$form_state) {
    $form['node-id'] = array(
        '#type' => 'textfield',
        '#title' => t('Enter the Node ID'),
        '#max-length' => 8,
        '#required' => 1,
    );
    $form['edit-node'] = array(
        '#type' => 'radios',
        '#title' => t('Select Action'),
        '#options' => array(t('edit'), t('delete')),
        '#required' => 1,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

function edit_node_form_validate($form, &$form_state){
    $query = db_query('SELECT nid FROM {node}');
    foreach ($query as $result) {
        if (!($form_state['values']['node-id'] != $result)) {
            form_set_error('node-id', 'Node-id must match a current nid.');
        }
    }
}

function edit_node_submit($form, &$form_state){
    if (form_state['values']['edit-node'] == 'edit'){
        $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit';
    }
    if (form_state['values']['edit-node'] == 'delete'){
        $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete';
    }
}

In the $form array do I need some sort of redirect handler to make it work? Or a print_r or render?

added 97 characters in body; edited title
Source Link

Custom Block Form Not redirecting to New Page

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button. Here is my code: function edit_node_block_info(){ $blocks['edit_node'] = array( 'info' => t('Custom Block to allow edit/delete/copy'), 'status' => 1, 'region' => 'Primary', 'weight' => 0, 'visibility' => BLOCK_VISIBILITY_LISTED, );

return $blocks;

} /*

  • Implements hook_block_view: sets how the block is displayed / function edit_node_block_view($delta = ''){ switch ($delta) { case 'edit_node' : $block['subject'] = t('Edit Nodes'); $block['content'] = drupal_get_form('edit_node_form'); break; } return $block; } /
  • implements custom form/creating custom form for drupal_get_form named above. */

function edit_node_form($form, &$form_state) { $form['node-id'] = array( '#type' => 'textfield', '#title' => t('Enter the Node ID'), '#max-length' => 8, '#required' => 1, ); $form['edit-node'] = array( '#type' => 'radios', '#title' => t('Select Action'), '#options' => array(t('edit'), t('delete')), '#required' => 1, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }

function edit_node_form_validate($form, &$form_state){ $query = db_query('SELECT nid FROM {node}'); foreach ($query as $result) { if (!($form_state['values']['node-id'] != $result)) { form_set_error('node-id', 'Node-id must match a current nid.'); } } }

function edit_node_submit($form, &$form_state){ if (form_state['values']['edit-node'] == 'edit'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit'; } if (form_state['values']['edit-node'] == 'delete'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete'; } } In the $form array do I need some sort of redirect handler to make it work?Or a print_r or render?

I also tried $link = (form_state['values']['node-id']);

Custom Form Not redirecting to New Page

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button. Here is my code: function edit_node_block_info(){ $blocks['edit_node'] = array( 'info' => t('Custom Block to allow edit/delete/copy'), 'status' => 1, 'region' => 'Primary', 'weight' => 0, 'visibility' => BLOCK_VISIBILITY_LISTED, );

return $blocks;

} /*

  • Implements hook_block_view: sets how the block is displayed / function edit_node_block_view($delta = ''){ switch ($delta) { case 'edit_node' : $block['subject'] = t('Edit Nodes'); $block['content'] = drupal_get_form('edit_node_form'); break; } return $block; } /
  • implements custom form/creating custom form for drupal_get_form named above. */

function edit_node_form($form, &$form_state) { $form['node-id'] = array( '#type' => 'textfield', '#title' => t('Enter the Node ID'), '#max-length' => 8, '#required' => 1, ); $form['edit-node'] = array( '#type' => 'radios', '#title' => t('Select Action'), '#options' => array(t('edit'), t('delete')), '#required' => 1, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }

function edit_node_form_validate($form, &$form_state){ $query = db_query('SELECT nid FROM {node}'); foreach ($query as $result) { if (!($form_state['values']['node-id'] != $result)) { form_set_error('node-id', 'Node-id must match a current nid.'); } } }

function edit_node_submit($form, &$form_state){ if (form_state['values']['edit-node'] == 'edit'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit'; } if (form_state['values']['edit-node'] == 'delete'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete'; } } In the $form array do I need some sort of redirect handler to make it work?

Custom Block Form Not redirecting to New Page

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button. Here is my code: function edit_node_block_info(){ $blocks['edit_node'] = array( 'info' => t('Custom Block to allow edit/delete/copy'), 'status' => 1, 'region' => 'Primary', 'weight' => 0, 'visibility' => BLOCK_VISIBILITY_LISTED, );

return $blocks;

} /*

  • Implements hook_block_view: sets how the block is displayed / function edit_node_block_view($delta = ''){ switch ($delta) { case 'edit_node' : $block['subject'] = t('Edit Nodes'); $block['content'] = drupal_get_form('edit_node_form'); break; } return $block; } /
  • implements custom form/creating custom form for drupal_get_form named above. */

function edit_node_form($form, &$form_state) { $form['node-id'] = array( '#type' => 'textfield', '#title' => t('Enter the Node ID'), '#max-length' => 8, '#required' => 1, ); $form['edit-node'] = array( '#type' => 'radios', '#title' => t('Select Action'), '#options' => array(t('edit'), t('delete')), '#required' => 1, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }

function edit_node_form_validate($form, &$form_state){ $query = db_query('SELECT nid FROM {node}'); foreach ($query as $result) { if (!($form_state['values']['node-id'] != $result)) { form_set_error('node-id', 'Node-id must match a current nid.'); } } }

function edit_node_submit($form, &$form_state){ if (form_state['values']['edit-node'] == 'edit'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit'; } if (form_state['values']['edit-node'] == 'delete'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete'; } } In the $form array do I need some sort of redirect handler to make it work?Or a print_r or render?

I also tried $link = (form_state['values']['node-id']);

Source Link

Custom Form Not redirecting to New Page

I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button. Here is my code: function edit_node_block_info(){ $blocks['edit_node'] = array( 'info' => t('Custom Block to allow edit/delete/copy'), 'status' => 1, 'region' => 'Primary', 'weight' => 0, 'visibility' => BLOCK_VISIBILITY_LISTED, );

return $blocks;

} /*

  • Implements hook_block_view: sets how the block is displayed / function edit_node_block_view($delta = ''){ switch ($delta) { case 'edit_node' : $block['subject'] = t('Edit Nodes'); $block['content'] = drupal_get_form('edit_node_form'); break; } return $block; } /
  • implements custom form/creating custom form for drupal_get_form named above. */

function edit_node_form($form, &$form_state) { $form['node-id'] = array( '#type' => 'textfield', '#title' => t('Enter the Node ID'), '#max-length' => 8, '#required' => 1, ); $form['edit-node'] = array( '#type' => 'radios', '#title' => t('Select Action'), '#options' => array(t('edit'), t('delete')), '#required' => 1, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; }

function edit_node_form_validate($form, &$form_state){ $query = db_query('SELECT nid FROM {node}'); foreach ($query as $result) { if (!($form_state['values']['node-id'] != $result)) { form_set_error('node-id', 'Node-id must match a current nid.'); } } }

function edit_node_submit($form, &$form_state){ if (form_state['values']['edit-node'] == 'edit'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit'; } if (form_state['values']['edit-node'] == 'delete'){ $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete'; } } In the $form array do I need some sort of redirect handler to make it work?