I am trying to send a value of select list with the form URL with the following HTML markup.
<select class="form-select" name="field_with_contact[und]" id="edit-field-with-contact-und"><option value="_none">- None -</option><option value="26">Rawhi Pharmacy</option></select>
The form URL is http://www.example.com/node/add/deal .
How can I send the value 26 to the form?
Thank you
You can use the Prepopulate module which is thought for exactly this purpose.
As shown in the project page, a URL like http://example.com/node/add/blog?edit[title]=this%20is%20the%20title
would pre-populate the title with this is the title .
The module can be used with every form, and it has an official release that is used (on August 6, 2017) from 5004 sites .
Before January 1, 2013, the usage of the module was the following.
As of August 18, 2017, the usage of the module for Drupal 6 decreased, since Drupal 6 is not officially supported anymore, but the total usage slightly increased thanks to its usage in Drupal 7 and Drupal 8 sites.
If you go to "www.mysite.com/node/add/deal/26" the following code will print The number passed in url was: 26
Here is the code:
function my_module_menu()
{
$items = array();
$items['node/add/deal/%'] = array(
'title' => 'Add deal',
'page callback' => 'drupal_get_form',
'page arguments' => array('node_add_deal_form', 3),
'access callback' => array(TRUE),
'type' => MENU_CALLBACK,
);
return $items;
}
function node_add_deal_form($form, &$form_state, $number)
{
$form = array();
$form['number'] = array(
'#markup' => '<p>The number passed in url was: '. $number. '</p>',
);
return $form;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.