hook_form_alter

Events happening in the community are now at Drupal community events on www.drupal.org.
python1340's picture

Omega template.php vs. preprocess/process

From what I understand, the proper place to put code to alter a form is in hook_form_alter. So I created a function mytheme_alpha_form_alter() and put it in template.php. Everything works fine, however the comments in template.php suggest that I should keep that file "as clean as possible" and to use the preprocess and process subfolders instead. So in trying to do things the proper alpha/omega way, I created a file preprocess/preprocess-page.inc and did the form modification code inside mytheme_alpha_preprocess_page(). This also works, but sure seems ugly.

Read more
kleve's picture

Taxanomi spårlöst försvunnen i node_form vid hook_form_alter

Hej

Har skrivit en liten modul som med hjälp av hook_form_alter tar Taxanomiernas olika vokabulär och lägger dessa i två olika fieldsets istället för Taxanomiernas default fieldset, detta för att dela upp vokabulären i node_form-formuläret. Jag har tagit scroll-listorna som ligger i $form['taxonomy'], flyttat dessa till nya fieldsets och sedan dolt $form['taxonomy']. Detta fungerar lokalt och på en testserver men när modulen läggs upp på produktionsserver så fungerar det inte.

Read more
sibaz's picture

Editing profile node as part of /user/%uid/edit page

I need to give a seamless implementation of a site, where users can edit a number of bits of information about themselves. The Default form in content_profile is to add tabs (primary or secondary) to the /user/%uid pages. The content_profile_registration module does it right, it allows you to tick a box, and so add the fields to the registration form, using hook_form_alter, to add fields to the 'user_register' form.

Is there a module which does the same for the user_profile_form? or hook_user($op=form, $category=account);

Read more
altrugon's picture

How to use AHAH inside a form_alter hook?

I'm trying to add AHAH functionality inside a hook_form_alter() to be able to add an icon next to the block titles.

Here is how all this procedure works:

Read more
kassissieh's picture

Lightweight electronic portfolio

I am using Drupal's blog module to provide a lightweight electronic portfolio tool to students and teachers. I could use your feedback on the approach I've taken using content_access and hook_form_alter. Is this the best/safest way to do this? I still feel like a relative newbie to making these modifications.

For a fuller example of the reason for using blog as a portfolio, please see http://www.kassblog.com/item/1030

I added a checkbox field to the blog content type.

Only local images are allowed.

<?php

Read more
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.

Read more
thehong's picture

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, ...

Read more
Subscribe with RSS Syndicate content