I want to be able to go off and query a third-party service and then prepopulate forms based on the result of that query. Instead of just writing a slab of custom code I generalised the problem so that you could define views-like argument handling code and insert the results of that code into a prepopulate query string. Attached is a very rough first pass at a module to do this.

So you would create a "prepopulate pattern" via an admin form thus:

Name:
user_page

Description:
Prepopulate a page node from a user account.

Form Path:
node/add/page

Argument-handling code:
$user = user_load(array('name' => $args[3]));
$args['name'] = $user->name;
$args['email'] = $user->mail;
return $args;

Prepopulate query arguments:
edit[title]=%name
edit[body_field][body]=%name can be contacted at %email

... and a path like prepopulate/user_page/dries or whatever would redirect you to node/add/page with the appropriate prepopulate query string.

What I would like some feedback on is:

  • Is this a sensible approach to the problem?
  • Has somebody else already solved the problem in this or some better way?
  • If neither of the above, should this module be fixed up and released as a separate project, or packaged in with the prepopulate module?

Comments

jbrauer’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing Drupal 6 issues no longer supported.