0

I have cretad a menu for edit a form in drupal...

Code:

function pricepackages_menu()
{
    $items = array();
    $items['membership/packages'] = array(
        'title' => t('Add Membership Packages'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('pricepackages_form'),
        'access arguments' => array('access administration pages'),
    );
    $items['show/packages'] = array(
        'title' => t('Manage Membership Packages'),
        'page callback' => 'view_packages',
        'access arguments' => array('access administration pages'),
    );
    $items['package/%/edit'] = array(
        'title' => 'Edit Membership',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('pricepackages_form_update'),
        'access arguments' => array('access administration pages'),
    );
    return $items;
}

3rd menu is for eidt purpose...

The codd to show form i worte is:

function pricepackages_form_update($form, &$form_state)
{
    $form['packagename'] = array(
        '#type' => 'textfield',
        '#title' => 'Package Name',
        '#required' => TRUE,
    );
}

Please let me know how can get the value of the id in the url :

URL : http://somedomain.com/package/1/edit

I want to get the id 1 from the url and than want to add a select query... please let me know how can i get that value so i can wrote teh select query...

Also do i have to specify a new parameter in the pricepackages_form_update() or not?

Thanks in advance...

2

1 Answer 1

0

Try It works for me.

$items['package/%/edit'] = array(
'title' => 'Edit data Row',
'page callback' => 'pricepackages_form_update',
'page arguments' =>array(1),
'type' => MENU_NORMAL_ITEM,
'access callback' => TRUE,
);


function pricepackages_form_update($arg){
$my_object = db_select('your table name', 'a')
->fields('a')
->condition('your node id parameter', $arg )
->execute()
->fetchAssoc();
return drupal_get_form('your form menu', $my_object);
}

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