Hi all, not very familiar with Drupal development, but I'm working my way through Pro Drupal Development which helps a lot. I was wondering how I could implement the hook_form, in order to create a form within the Drupal generated form. Can I add php in the <mymodule>_form or does Drupal offer ways here? Here is my case. I am creating a module that stores nodes with several textfields. One of the fields is mandatory and should contain a url. The user must be able to search for the urls by posting keywords to an web service. When the result comes back the user must be able to select a url which is then stored in the right field. after that, the user is able to add some text and then submit the form the Drupal way. Any help is welcome, thanks advance for the trouble taken. Ole Kerpel Developer Internationaal Instituut voor Sociale Geschiedenis Postbus 2169 1000 CD Amsterdam T: 0208500137 E: oke@iisg.nl www.iisg.nl
HI, See Chapter 10 The Form API in Pro Drupal Development. CK On Jul 27, 2009, at 12:24 PM, Ole Kerpel wrote:
Hi all,
not very familiar with Drupal development, but I'm working my way through Pro Drupal Development which helps a lot.
I was wondering how I could implement the hook_form, in order to create a form within the Drupal generated form. Can I add php in the <mymodule>_form or does Drupal offer ways here?
Here is my case. I am creating a module that stores nodes with several textfields. One of the fields is mandatory and should contain a url. The user must be able to search for the urls by posting keywords to an web service. When the result comes back the user must be able to select a url which is then stored in the right field. after that, the user is able to add some text and then submit the form the Drupal way.
Any help is welcome, thanks advance for the trouble taken.
Ole Kerpel Developer
Internationaal Instituut voor Sociale Geschiedenis Postbus 2169 1000 CD Amsterdam T: 0208500137 E: oke@iisg.nl www.iisg.nl
Ole, Would an autocomplete textfield work in your situation? Basically, when text is entered in the textfield, it triggers a function which takes the text and returns a list of results the user can select from. In your case, they user could type the textfields into the textbox, and the autocomplete function could return a list of URLs the user can select from. There's a quick set of instructions on autocomplete fields at http://drupal.org/node/208424#comment-686252. You can get more info by searching drupal.org. Brian Vuyk Web Design & Development T: 613-534-2916 brian@brianvuyk.com | http://www.brianvuyk.com Ole Kerpel wrote:
Hi all,
not very familiar with Drupal development, but I'm working my way through Pro Drupal Development which helps a lot.
I was wondering how I could implement the hook_form, in order to create a form within the Drupal generated form. Can I add php in the <mymodule>_form or does Drupal offer ways here?
Here is my case. I am creating a module that stores nodes with several textfields. One of the fields is mandatory and should contain a url. The user must be able to search for the urls by posting keywords to an web service. When the result comes back the user must be able to select a url which is then stored in the right field. after that, the user is able to add some text and then submit the form the Drupal way.
Any help is welcome, thanks advance for the trouble taken.
Ole Kerpel Developer
Internationaal Instituut voor Sociale Geschiedenis Postbus 2169 1000 CD Amsterdam T: 0208500137 E: oke@iisg.nl www.iisg.nl
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ole Kerpel wrote:
I was wondering how I could implement the hook_form, in order to create a form within the Drupal generated form. Can I add php in the <mymodule>_form or does Drupal offer ways here?
Here it certainly sounds like you want hook_form_alter. You have a Drupal generated form and you can add stuff to it.
Here is my case. I am creating a module that stores nodes with several textfields. One of the fields is mandatory and should contain a url. The user must be able to search for the urls by posting keywords to an web service. When the result comes back the user must be able to select a url which is then stored in the right field. after that, the user is able to add some text and then submit the form the Drupal way.
Is it possibly an idea to make this field a special CCK (text/url) field with appropriate widget? From what I understand, above, it is a two stage process - so take this example: the node_reference field with the http://drupal.org/project/popups_reference addition (if I recall correctly it makes a jquery 'pop up' for creating the node which it then uses to populate the node reference field). ekes - --- http://drupal.org/user/10083 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkputxcACgkQR9het8OQC6VkjgCeIr2lomJ62HsgiCrNzWH6NyGM baUAni5WEye2Mtxl3QqgHlsfj8UOhKP0 =xDkR -----END PGP SIGNATURE-----
participants (4)
-
Brian Vuyk -
Bushidodeep -
ekes -
Ole Kerpel