🇨🇦Canada @psaleks

Account created on 20 December 2007, almost 17 years ago
#

Recent comments

🇨🇦Canada psaleks

Try Easy Entity Base Field . I did test and it works with ECK.
To see fields in Views - clear cache.

🇨🇦Canada psaleks

Views integration works after clear cache.

🇨🇦Canada psaleks

I want to reopen this issue, because I do not like to use table with numbers (that usually align to right) without align and create extra module for this. Align settings should be in module without extra coding for each site.

I looked in the code version 1.0.19 and change a little only for mode Table. Please can you review changes and if possible to add to module.

1. css/tablealign.css
2. datafield.libraries.yml Add to end
datafield_table_align:
css:
component:
css/tablealign.css: { }

3. src/Plugin/Field/FieldFormatter/DataFieldTable.php Inside file I entered changes between lines //my .....//endmy( 7 changes). Example below

  foreach ($subfields as $subfield) {
      $item = $field_settings['columns'][$subfield];
      $title = $field_settings["field_settings"][$subfield]["label"] ?? $item['name'];
      $element['formatter_settings'][$subfield]['column_label'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Column label: %title', ['%title' => $title]),. 
        '#attributes' => ['placeholder' => $this->t('Column label')],
        '#default_value' => $setting[$subfield]['column_label'] ?? $title,
      ];
//my
      $element['formatter_settings'][$subfield]['align'] = [
        '#type' => 'select',
        '#title' => $this->t('Align'),               
        '#default_value' =>!empty($setting[$subfield]['align']) ? $setting[$subfield]['align']: '',
				'#options' => [
          '' => $this->t('None'),
          'data-field-align-left' => $this->t('Left'),
          'data-field-align-center' => $this->t('Center'),
          'data-field-align-right' => $this->t('Right'),
        ],
      ];				
//endmy		

I attached files. Last two i added extension txt for uploading

🇨🇦Canada psaleks

Thank you lazzyvn . 'Entity reference type by Views' works in version 1.0.18.

🇨🇦Canada psaleks

Install Drupal core. Install data field.
Create two contents A and B.
Add to content B reference field to content A: refA, select content A. This part works same for Data Field.

Create view for content A with title. In same view add second view display: Entity Reference. It can be many fields, here use same title. Under Format do Settings for Format and Show (click checkboxes for title). Under fields for title - uncheck Link to the Content.
Save view.

Go to field refA, edit. Go to Reference type. You will see Reference method. Select option 'Views: Filter by an entity reference view' and select your Entity Reference view. This part does not work in Data Field if you start to do reference field in data field.
I attached two images: from view and field.

🇨🇦Canada psaleks

Same issue as Field reference do not use order (asc,desc) 🐛 Field reference do not use order (asc,desc) that done in views reference Fixed
Problem with Problem with incorrect optimization in EntityReference_SelectionHandler_Views.class.php. v7.x-1.8 from
line 142

🇨🇦Canada psaleks

Problem with incorrect optimization in EntityReference_SelectionHandler_Views.class.php. v7.x-1.8
line 142

      $target_type = $this->field['settings']['target_type'];

      // Do not load the entire entity for performance reasons.
      $entity_info = entity_get_info($target_type);
      $query = db_select($entity_info['base table'], 'e');
      $query->fields('e');
      $query->condition('e.' . $entity_info['entity keys']['id'], array_keys($result), 'IN');

      foreach ($query->execute() as $entity) {
        // When the bundle key is not on the 'base table', get it on the $entity
        // through entity_load().
        if (!empty($entity_info['entity keys']['bundle']) && empty($entity->{$entity_info['entity keys']['bundle']})) {
          $loaded_entities = entity_load($target_type, array($entity->{$entity_info['entity keys']['id']}));
          if (empty($loaded_entities)) {
            continue;
          }
          $entity = reset($loaded_entities);
        }
        list($id,, $bundle) = entity_extract_ids($target_type, $entity);
        $return[$bundle][$id] = $result[$id];
      }

To fix bug replace by code from v7.x-1.6

      $target_type = $this->field['settings']['target_type'];
      $entities = entity_load($target_type, array_keys($result));
      foreach($entities as $entity) {
        list($id,, $bundle) = entity_extract_ids($target_type, $entity);
        $return[$bundle][$id] = $result[$id];
      }
Production build 0.71.5 2024