hook_form_alter

jersu's picture

Which is more efficient - hook_form_alter or hook_menu_alter - for replacing a single page?

I'm replacing a single page from a contributed module. The page is currently rendered with a call to drupal_get_form() from a path like foo/%node/bar

My first thought was to replace the page with hook_form_alter, unset the form elements, and replace with my own content. But I thought that would require a whole lot of preprocessing on the form that I would just discard.

So, my next thought was to just redirect the path to my own function with hook_menu_alter. But, is this less efficient because of the dynamic nature of the path?

I'm just curious if anyone has experience with this.

3 comments

Sức mạnh hook_form_alter

hook_form_alter là một công cụ cực kỳ mạnh mà Drupal cung cấp. Chúng ta có thể sử dụng nó để thực hiện được nhiều việc, tưởng chừng như không thể: Thay đổi cấu trúc một form mà không cần sửa mã nguồn, định dạng form, thêm kịch bản xử lý cá nhân vào form hệ thống, ...

Login to post comments · Read more
Syndicate content