Skip to main content
fix code not appearing
Source Link
Apemantus
  • 567
  • 5
  • 13

What do you mean "generate form on the fly"? As in: the form for page "page/form" doesn't exist in a canonical state but is generated based on variables such as date/url/taxonomy? Or is it just the default values for the form etc?

In any wayanyway: the options to have a form on a page are:

  1. Hardcode HTML into the node content, e.g. etc<form><input> etc
  2. Use hook_menu to create the page and use either the form API
  3. Use hook_menu to create the page and use the straight HTML
  4. Use hook_nodeapi to add a form to the content via hook_nodeapiwith the Form API
  5. Use hook_nodeapi to add a form to the content via hook_nodeapiusing HTML
  6. Use a module such as webforms to add the forms

I would suggest either 2 or 4. When you say that hook_menu generates these plages "on teh fly": that's not true. hook_menu is only run on cache clear, and assuming you're using caching then the generation of forms isn't going to make much difference to your server. This may be a case where you're sweating about optimisation unnecessarily.

Using Form API gives you a load of tools that you'd otherwise have to handle yourself - validation, submission, sanitising, standardising, etc.

What do you mean "generate form on the fly"? As in: the form for page "page/form" doesn't exist in a canonical state but is generated based on variables such as date/url/taxonomy? Or is it just the default values for the form etc?

In any way: the options to have a form on a page are:

  1. Hardcode HTML into the node content, e.g. etc
  2. Use hook_menu to create the page and use either the form API
  3. Use hook_menu to create the page and use the straight HTML
  4. Use hook_nodeapi to add a form to the content via hook_nodeapi
  5. Use hook_nodeapi to add a form to the content via hook_nodeapi
  6. Use a module such as webforms to add the forms

I would suggest either 2 or 4. When you say that hook_menu generates these plages "on teh fly": that's not true. hook_menu is only run on cache clear, and assuming you're using caching then the generation of forms isn't going to make much difference to your server. This may be a case where you're sweating about optimisation unnecessarily.

Using Form API gives you a load of tools that you'd otherwise have to handle yourself - validation, submission, sanitising, standardising, etc.

What do you mean "generate form on the fly"? As in: the form for page "page/form" doesn't exist in a canonical state but is generated based on variables such as date/url/taxonomy? Or is it just the default values for the form etc?

In anyway: the options to have a form on a page are:

  1. Hardcode HTML into the node content, e.g. <form><input> etc
  2. Use hook_menu to create the page and use the form API
  3. Use hook_menu to create the page and use the straight HTML
  4. Use hook_nodeapi to add a form to the content with the Form API
  5. Use hook_nodeapi to add a form to the content using HTML
  6. Use a module such as webforms to add the forms

I would suggest either 2 or 4. When you say that hook_menu generates these plages "on teh fly": that's not true. hook_menu is only run on cache clear, and assuming you're using caching then the generation of forms isn't going to make much difference to your server. This may be a case where you're sweating about optimisation unnecessarily.

Using Form API gives you a load of tools that you'd otherwise have to handle yourself - validation, submission, sanitising, standardising, etc.

Source Link
Apemantus
  • 567
  • 5
  • 13

What do you mean "generate form on the fly"? As in: the form for page "page/form" doesn't exist in a canonical state but is generated based on variables such as date/url/taxonomy? Or is it just the default values for the form etc?

In any way: the options to have a form on a page are:

  1. Hardcode HTML into the node content, e.g. etc
  2. Use hook_menu to create the page and use either the form API
  3. Use hook_menu to create the page and use the straight HTML
  4. Use hook_nodeapi to add a form to the content via hook_nodeapi
  5. Use hook_nodeapi to add a form to the content via hook_nodeapi
  6. Use a module such as webforms to add the forms

I would suggest either 2 or 4. When you say that hook_menu generates these plages "on teh fly": that's not true. hook_menu is only run on cache clear, and assuming you're using caching then the generation of forms isn't going to make much difference to your server. This may be a case where you're sweating about optimisation unnecessarily.

Using Form API gives you a load of tools that you'd otherwise have to handle yourself - validation, submission, sanitising, standardising, etc.