I'm trying to figure out how (or if it's even possible) to create a new node with "suggested" values. That is, I want to have a custom "create new node" link with parameters supplied that would then show up as suggested starting values in the submit form that is generated. For instance, if i had a page with a link like this:
/node/add/page?suggest_title="fancy title"
Then when clicking on the link, it would open up the submit page form, but the title would have the "fancy title" filled out already as the suggested default value. In my case I'm doing this with a custom module with custom content types, so I have access to all the necessary hooks, etc. But in my hook_submit handler, I can see no way at all to access any extra parameters or stuff that might have come in with the call. Does anyone have any ideas on how to do this, or reasons it can't work? Thanks...
Comments
hook_form
Shouldn't you be inserting these at hook_form? Here you have access to regular $_GET variables. You could do something like:
<?php
function mymodule_form(&$node) {
$title = _validate_user_input($_GET['suggest_title']);
$form['title'] = array (
'#default_value' => $title,
'#type' => etc...
);
return $form;
}
function _validate_user_input ($input) {
// Validate the input here. Check for possible SQL injection, etc...
return $input;
}
Oh, yah, hook_form was what
Oh, yah, hook_form was what I meant, rather than hook_submit. However the $_GET variable is what I was missing out on. Didn't know that existed, and it has exactly what I need. Thanks! :)