There is the ability to use #skip_edit for field API fields, but how can I make it so that the node title is not editable via the edit module?

Comments

rooby’s picture

Title: How to skip edit of the node title » Add a #skip_edit equivalent for pseudo fields
Category: Support request » Feature request

After a little investigation I see I can override theme_edit_wrap_field() to not add the wrapper but that seems a bit hackish.

Maybe this should instead be a feature request.

When pseudo field are generated we have access to the entity type, entity id, field name, language, view mode, and bundle, so we could have a hook that gets called with that info and modules can return false to deny editing.

That's the first idea that springs to mind but there are a bunch of ways it could be done.

rooby’s picture

Component: Documentation » Code
Wim Leers’s picture

Title: Add a #skip_edit equivalent for pseudo fields » Ability to override metadata of extra fields (e.g. to make the title NOT in-place editable)
Assigned: Unassigned » Wim Leers
Status: Active » Fixed
Issue tags: +Spark

You'll want to use hook_edit_editor_metadata_alter() to do that :) As you already say, there's no clear way to do this because titles aren't rendered using the Render API.

You'll want to do something like this:

/**
 * Implements hook_edit_editor_metadata_alter()
 */ 
function yourmodule_edit_editor_metadata_alter(&$metadata, $context) {
  if ($context['entity_type'] === 'node' && $context['field_name'] === 'title') {
    $metadata['access'] = FALSE;
  }
}

EXCEPT… that that hook is also called exclusively for non-extra fields. So I updated the invocation of that hook, added a little bit more context, and now the above exact code works: I tried it myself :)

http://drupalcode.org/project/edit.git/commit/afa601d

rooby’s picture

Great, thank you.

Wim Leers’s picture

You're welcome!

Status: Fixed » Closed (fixed)

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