1

Ok. So I have a content type, let's say "My favorite places". So naturally Drupal has a form to create new "favorite place" at node/add/my-favorite-places which appears as a page. I managed to create a customized template for this form my_favorite_places-node-form.tpl.php following this very helpful thread. How do you theme a content type's create/edit form in Drupal 7?

I'd like to use this form in several pages on my site. So I was thinking to make it into a block. In below mockups, My favorite places = Content Type A.

Page 1 Page 2 Pushing my luck Page 3

However...... I had some experiences customizing front page for anonymous users showing login & register form at the same time, which doesn't run properly with a block (messaging issue). An expert mentioned that form rendering calls should never be fired from inside blocks.

So, I was wondering whether this is a good idea. And if so, how should I do that, if possible without installing another contrib module.

Please advise. Thanks.

2 Answers 2

0

You can definitely use forms inside blocks but its always best to run them through Drupal's form API to benefit from their security layers. Alejandro's suggestion to use drupal_get_form is right but you might find it easier to use the Advanced Form Block module which does exactly what you are asking, including creating multiple form blocks of the same content type. You create a block through their interface, chosing the content-type you want to create, and its then available to place through blocks admin or context, etc.

1
  • I guess I have no other choice other than that module. At least for now... Thanks schnippy. Commented Sep 5, 2013 at 1:49
0

Using php inside blocks or simply pouring your database with php used to be bad practice.

Said that, the function toy are looking for is drupal get form:

https://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_get_form/7

1
  • Thanks Alejandro. I used it before to combine the login + reg forms together on front page. Commented Sep 5, 2013 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.