1

Im on d7. I want to have a block on the landing page of my site that has a "enter your title here" input field. When a user enters something in it and clicks continue, they are directed to the node submission form and the title field should be populated with what they had just entered. How would I put something like his together? Thanks?

1

Use the Prepopulate module, there is an example on the docs for pre-populating the title field. All you need is to have a simple form that appends your $data to this path:

/node/add/yourcontenttype?edit[title]='.'$data'
2
  • So I've checked out the prepopulate module and its exactly what I need. I can get it to work for a normal link with some static text, but Im having trouble building a simple form and having it pass the value into the title field.
    – oobie11
    Jan 30 '12 at 20:14
  • figured it out below
    – oobie11
    Jan 30 '12 at 20:46
0

Figured it out. Using the prepopulate module for anyone wanting to do the same thing, here is what my simple form looks like:

<form id="my_form" method="get" action="/node/add/content">
<input name="edit[title]=" type="text">
<button class="submit" type="submit">Go!</button>
</form>

This gets the value of the input and after hitting the submit button, populates the title field of my content type. Im giving credit to @ipwa for directing me to the prepopulate module. Thanks.

0

You can create a panel page with arguments and add field panes or custom plugins.

For example create panel page (/admin/structure/pages) and set the Path to like /confirmation/%node, where %node is your context argument loaded from the URL. Then in Panel Content you can add content panes which will use these substitutions (like %submission:field-some). The page title you can set up either using Substitutions as well, or load it from the pane. You can also code custom ctools plugin, for example:

/**
 * @file
 * CTools plugin to provide render a submission page.
 */

/**
 * Defines the Plugin.
 *
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  'single' => TRUE,
  'title' => t('Submission page'),
  'description' => t('Displays the submission form'),
  'edit form' => 'foo_submission_page_edit_form',
  'render callback' => 'foo_submission_page',
  'defaults' => array('foo_field' => ''),
  'all contexts' => TRUE,
);

/**
 * Implements pane render callback.
 */
function foo_submission_page($subtype, $conf, $panel_args, $contexts) {
  $block = new stdClass();
  $block->title = $conf['override_title'] ? $conf['override_title_text'] : '';
  $block->content = '';
  if (empty($contexts)) {
    return $block;
  }
  if (isset($conf['foo_field'])) {
    $text = ctools_context_keyword_substitute($conf['foo_field'], array(), $contexts);
    if ($text['value']) {
      $block->content = theme('foo_submission_page', array(
        'text' => check_markup($text['value'], $text['format']),
      ));
    }
    else {
      $block->content = '';
    } 
  }       

  return $block;
}

/** 
 * Implements pane edit callback.
 */
function foo_submission_page_edit_form($form, &$form_state) {
  $conf = $form_state['conf'];
  $form['foo_field'] = array(
    '#title' => t('Some field'),
    '#description' => t('Please provide extra info'),
    '#type' => 'textfield',
    '#default_value' => isset($conf['foo_field']) ? $conf['foo_field'] : '',
  );
  return $form;
}

/**
 * Submit handler for the pane edit form.
 */
function foo_submission_page_edit_form_submit($form, &$form_state) {
  foreach (array_keys($form_state['plugin']['defaults']) as $key) {
    if (isset($form_state['values'][$key])) {
      $form_state['conf'][$key] = $form_state['values'][$key];
    }
  }
}

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.