I'd like to be able to lay out a custom form created using the Bean API with display suite (ds_forms & rel modules). I'm wondering if registering the form elements using hook_field_extra_fields() would help? See #1490328: Adding fields to node edit form via hook_form_alter and placing them in DS regions.

Also, the bean form's ID is always bean_form which means that if display suite is customising the form and extra fields are added in DS all other bean forms get these elements added. Would it be possible to change the form ID to something like bean_form_{$bean_type}?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

indytechcook’s picture

I like this idea. It's good Drupal practice also.

indytechcook’s picture

Pulling related issue #1647542: Making Bean Title accessible to Views Mode

I was reading this article by one of the BEANS contributors, View Modes: Add 'Extra Fields' to Your Content, and trying to adapt this practice to BEANS and entities.

My goal is to have my BEAN titles be accessible to View Modes, so I can order them, show them, hide them, etc., like all the other entity fields.

That article shows how to do it for Nodes, but it doesn't work for entities. I hoped someone here has already done this and can help. I understand that it's hook_entity_view instead of hook_node_view, but that's as far as I can take it.

broeker’s picture

Here is a patch that provides support for hook_field_extra_fields().

In my case, I am just using hook_entity_view() in a custom module to handle the actual output, but this patch provides the necessary support for the Manage Display UI within the Beans admin. This allows you to drag and drop your title ("Bean field: Title") within your view mode. I'm not actually using Display Suite, so I'm not sure how they handle the field output or if you will need additional steps to actually alter your view mode, but this patch will be required either way and should cause the Bean field: Title field to show up in the view modes UI.

indytechcook’s picture

Status: Active » Needs review

Setting to Needs review so testbot can run.

skwashd’s picture

The patch from @broeker at #3 looks good to me. I think it is good to allow users to be able to reorder the fields in the form too, so I've added that to the patch.

indytechcook’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

indytechcook’s picture

Status: Reviewed & tested by the community » Fixed
johnnybgoode’s picture

implementation of hook_block_view_alter to support the title field added by hook_extra_fields in the patch from #5.

function <my_module>_block_view_alter(&$data, $block) {
  if ($block->module == 'bean') {                                                         
    $bean = $data['content']['bean'];
    foreach($bean as $idx => $bean) {
      $data['content']['bean'][$idx]['title'] = array(
        '#markup' => '<div class="field field-name-title">' . $data['subject'] . '</div>'
      ); 
      $data['subject'] = '';
    }     
  }      
}

Status: Fixed » Closed (fixed)

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

mducharme’s picture

Version: 7.x-1.x-dev » 7.x-1.2
Status: Closed (fixed) » Active

The default Bean title is still not configurable in Display Suite as per #1647542: Making Bean Title accessible to Views Mode.

I tried using the extra fields DS feature with the entity|bundle|field setting of "bean|my_block_type|title" but it basically breaks the title field (can provide details if useful).

oxyc’s picture

I made a quick module to support this better. It replaces the beans own extra field and adds a ds field with the same settings as nodes/terms/etc (setting heading tag, classes etc).

https://github.com/generoi/bean_ds

davidwbarratt’s picture

Issue summary: View changes

oxyc,

Can you put your module on Drupal.org?

Thanks!

Leo Pitt’s picture

I've worked around the problem of bean title fields not respecting manage display settings using the https://www.drupal.org/project/title module.

Use it to replace the bean title field with a field entity - this will place the title field into the content array where it can be properly managed via display settings and display suite.

You'll then have two titles - one coming from the block template h2 and the other from the content array. I created a new block template block--bean.tpl,php with the title h2 removed and that seems to work.

Leeteq’s picture

gordon’s picture

I needed this fixed, and also found a problem in display suite that stopped the title from displaying when overriding the layout. I have submitted the issue #2908712

Here is my patch to bean which adds ds support.

gordon’s picture

Title: Make custom bean forms compatible with Display Suite » Make custom bean compatible with Display Suite
Status: Active » Needs review
FileSize
4.83 KB

I merged in the previous patch which also makes it compatible with bean forms as well.

gordon’s picture

Opps, broke something.

The last submitted patch, 16: make_custom_bean-1534722-16.patch, failed testing. View results

DamienMcKenna’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
MaxMendez’s picture

Tested patch #17 and works fine in my environment.