How do I add and display the page view entity fields implements in hook_shema, but not fields of add fields API?

I created custom entity of Entity API. I added fields in hook_shema. These fields is work, but not display in the page view entity

Help please!

Comments

lukasss’s picture

Help please!

For world peace!

WorldFallz’s picture

database fields of an entity are not 'fields' to drupal and they won't behave as field api fields when handling/viewing the entity. They're considered 'properties'-- you'll need to expose them for viewing yourself via entity meta data wrappers.

lukasss’s picture

the solution here: https://www.drupal.org/node/2220557
I got to add all the properties of an entity in "control of the display", while I added (except, of course, controllers), only here it is:

 class MyEntityMetadataController extends EntityDefaultMetadataController {
  public function entityPropertyInfo() {
    $info = parent::entityPropertyInfo();
    return $info;
  }
}

To output directly to the $ content that's in product_build_content:

  $product->content['level_1'] = array(       
    '#markup' => $product->level_1,
    '#prefix' =>'<span class="field-label">'.t('Level 1').':</span><div class="field-level_1 inline">',
    '#suffix' => '</div>',      
  );
 
  $product->content['level_2'] = array(
    '#markup' => $product->level_2,
    '#prefix' =>'<span class="field-label">'.t('Level 2').':</span><div class="field-level_2 inline">',
    '#suffix' => '</div>',
  );

In general, it is clear that if we want to get a good performance, it is possible to do so, but if full: multilingual, setting visibility label .... it is still a lot of work

That's what The result was: https://github.com/lukasvs/entity_with_properties_as_fields

For world peace!