Is there any command or method that I can use to insert the contents of a form (e.g. the user registration form) into a block?
+3
A:
drupal_get_form($form_id)
- put it in a module's hook_block
($op=='view') or even... shudder... inside a block with PHP filter on.
You need to find the form id first - look for a hidden input
with the name form_id
within the form. Its value should be the the form id.
Also, you could simply use the Form Block module.
Eli Krupitsky
2009-09-20 14:10:25
Thanks. That did the trick. But why the shudder?
RD
2009-09-20 14:29:41
Basically, PHP filter is a bad idea. From Drupal's handbook page on the subject: "... it is a significant and dangerous security risk in the hands of a malicious user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code". You're almost always better off writing a module (just a couple of lines of overhead, really).
Eli Krupitsky
2009-09-20 15:50:46
One anecdote, I had a minor syntax error in a node with the PHP filter. It broke search indexing, which broke cron. It's not worth the debugging complexity.
Grayside
2009-09-20 17:18:28
I agree with Grayside. With my very first Drupal site I had php redirects in some nodes, which completely broke the search indexing module. So in that sense it is bad.
RD
2010-08-07 06:33:38
+1
A:
One other thing is that it puts some of the PHP code into the database, instead of in the filesystem where the rest is. It's easy to forget and waste a lot of time searching for the code, and grep is a lot more convenient that going through every block and seeing if the PHP is there.
Graham
2009-09-21 16:14:09