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_pageDescription:
Prepopulate a page node from a user account.Form Path:
node/add/pageArgument-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?
| Comment | File | Size | Author |
|---|---|---|---|
| prepopulate_patterns-6.x-0.1-20090908.tgz | 3.43 KB | Matthew Davidson |
Comments
Comment #1
jbrauer commentedClosing Drupal 6 issues no longer supported.