Hi
I am developing a module which allows people to advertise employment opportunities. The module works as a node type with some additional fields. This module should make it easy for people to maintain the published information.
I.e. by automatically deleting/hiding an employment opportunity (node) after a particular date has past. Another example how the module should make it easier for people to maintain the information is to store each node of this type in a pre-defined location in the menu-tree. (I would do that as an additionally SQL statement in hook_insert() ) Therefore I would like to "hide" the "Menu settings". The only way I found to do that would be to hack menu.module's menu_form_alter function in such a way that it does not alter form at all if the $form_id == MyFormID. Does anybody have a better idea how I can "hide" particular fields in the node form.
Thx
Comments
Start by looking at the form as a "regular" user.
Unless you have granted "regular" user's the 'administer menu' permission they should not see 'Menu settings'. In general unless you have granted the approriate permissions users see a pretty minimal form already.
Thanks, that worked for not displaying "Menu settings".
But I was looking for a coding option like:
hook_form_alter() { remove_form_element($form['menu']);}
In this case I am not displaying "Menu settings" and set any menu related input via direct SQL insertion in my_module_insert(). I would confuse an admin user who got permission to change the menu by overriding his input (behind the scene), therefore I would like to hide "Menu settings" in any case. Also I would like to do the same thing with other form elements e.g. url_alias, upload.
I can achieve that by hacking the related module's hook_form_alter() implementation - but I would like to keep the code related to my module in my module.
thanks for any advice
Form element hiding
You can use the unset($form['']); in your hook_form_alter()
or
You can do by taking the css id of that element and go to .css
put #id { display: none; }
If you find better way than this than also let me know.
Because same problem solution I need but not in above ways.
Thanx.
you may have to change your module's weight
for now, i'll ignore whether this is a good idea or not...
Why don't you just change user permissions for "administer menu"?
if that is not sufficient, you could try the following:
if you find that the $form you get to your module's hook_form_alter doesn't have an index, e.g. $form['menu'], it may be an indication that your module is firing before the form is fully built, ie. before menu.module :: menu_form_alter fires.
If that's the case, you'll have to change your module's weight in the system table.
You can do this manually (bad) or you can use a hook_update_N in your .install file (good).
First, check the weight of the menu module in the system db table (call this $w).
Then, set your module's weight to $w++