Hello, I was just looking for a way to hide the "URL path settings" fieldset for a couple 7.x sites but I can't find the $form['path'] array anymore..

In D7 hiding other things works with hook_form_alter but not path settings:

function hook_form_alter(&$form, &$form_state, $form_id) {
    switch ($form_id) {
        case 'page_node_form':
             $form['comment_settings']['#access'] = FALSE;  //hide comment settings works
             $form['path']['#access'] = FALSE;  //hide url path settings doesn't work
        break;
    }
}

Any ideas?

Greets

Comments

Wappie08’s picture

Title: Cannot $form['path'] to use form alter » Cannot find $form['path'] to hide form URL path settings
dave reid’s picture

Status: Active » Fixed

You have to ensure that your code gets run after path_form_node_form_alter().

In order of execution: hook_form_alter(), hook_form_BASE_FORM_ID_alter(), and then hook_form_FORM_ID_alter().

So your best bet is to use hook_form_page_node_form_alter() to modify $form['path'].

Wappie08’s picture

Status: Fixed » Active

Hi Dave, thanks for the quick reply! But theres still no $form['path'] in hook_form_FORM_ID_alter(), I also searched for another variablename but everything seems to be there exept path..

Wappie08’s picture

Still can't find a way to hide path settings, I can hide everything else with form_alter, does anybody got this working?

Greets

stevek123’s picture

I'm having the same problem. I can hide everything except "URL path settings" in my edit form for a "child" node. Here is the code in node.module (please note: the content type is "child"):

function node_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'child_node_form') {
$form['field_child_node']['#access'] = false;
$form['revision_information']['#access'] = false;
$form['options']['#access'] = false;
$form['path']['#access'] = false;
$form['comment_settings']['#access'] = false;
$form['author']['#access'] = false;
}
}

Thanks for any assistance.

stevek123’s picture

I don't know why, because I haven't taken the time to walk through the code yet, but this module, http://drupal.org/project/nodeformsettings, seems to work for hiding the path prompt on forms. After installing and enabling the modle, go to the relevant content type and click the "edit" link for the content type. A new link for "Node form settings" will allow you to hide the "Path" field, along with others.

dave reid’s picture

@stevek123: That's because core's URL alias 'path' fieldset gets added in path_form_alter, which runs after your node_form_alter since both modules have a weight of 0 and p > n alphabetically.

dave reid’s picture

Status: Active » Fixed

#7 also answers the original comment

Wappie08’s picture

Thanks very much, I'll give my module some weight :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hellomobe’s picture

Status: Closed (fixed) » Active

Sorry to reopen. My custom module has a weight of 99. I'm still not able to get the $form['path'] disabled with hook_form_FORM_ID_alter(). Please advise.

KayBe’s picture

These menu items are added to the form after the alter of the form takes place. You can use an after build to hide these menu's.
In your alter:

function cowork_form_booking_node_form_alter(&$form, &$form_state){
	$form['#after_build'][] = 'custom_after_build';
        ....
}
function custom_after_build($form, &$form_state) {
		$form['path']['#access'] = FALSE;
	$form['menu']['#access'] = FALSE;
	return ($form);	
}

This will remove the items from the form after the build of the form is created.
Regards,
Kris

bethhauck’s picture

After build works great, thanks for the explanation, KayBe!

Tony Finlay’s picture

Can you explain a little further how answer #12 works and if it'll work for taxonomy_term_form?

Thanks

dave reid’s picture

Status: Active » Fixed

Solution provided in #12.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

newme154’s picture

Issue summary: View changes

I have a view that has a link as one of the fields. the display shows the entire link path i.e, http://www.example.com/user i want just the /user to show up in the view. is this something that requires a rewrite or a creation of a template? any ideas?

dave reid’s picture

@newme154: Please file a support request in Views. This seems unrelated to Pathauto, and you are posting on an issue which has been marked closed/resolved for over a year.

mitchelljj’s picture

#12 works great for taxonomy terms!!!!!