Community Documentation

Pre-populating Menu Dropdown on Node Add

Last updated February 9, 2010. Created by amariotti on June 2, 2008.
Edited by Melissamcewen. Log in to edit this page.

To use the prepopulate.module to change dropdown menus is a little more complicated. Here are two use cases:

Form Information:
<select id="edit-menu-pid" class="form-select" name="menu[pid]">

Pre-populate URL:
http://your-site-name.com/node/add/your-content-type?edit[menu][pid]=59

Here the goal is to have the URL populate the parent item in the menu options, so that the node will be in a specific section. Simply writing in the text value of the option does not work, there is a specific option value instead. To find the option value and the select value, view the source.

<select name="menu[parent]" class="form-select menu-title-select" id="edit-menu-parent" >...
<option value="primary-links:789" selected="selected">-- ABOUT US</option>

In this case the select value is [menu][parent] and the option value is "primary-links:789," so the code is
http://your-site-name.com/node/add/your-content-type?edit[menu][parent]=primary-links:789

About this page

Drupal version
Drupal 5.x

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.