Hello,

I didn't find any way to display and edit the fields added to the relation, how can I do?

Thanks, regards,
Maurizio

CommentFileSizeAuthor
#6 1318540-6.patch2.63 KBchromix

Comments

deryck.henson’s picture

Make sure you have created at least one relation already or it won't show at all.

manuelBS’s picture

Same thing for me. I see all the Relations but if I have a relation with additional fields, I cannot edit these fields on inserting the relation. Is there a possibility or is that a feature request?

imiksu’s picture

Title: Where are the relation fields shown? » Widget doesn't get populated correctly

I can confirm this.

Steps:

  1. Add relations with relation select
  2. Save content
  3. Edit content

I have checkbox field attached to my relation type, so can be related to that maybe?

I also think that #1343338: Related nodes don't show when editing node is duplicate of this, so I've marked that issue as duplicate.

EDIT: I actually get this bug still if I do a relation type without extra fields...

Nibbleke’s picture

Had the same problem. solved it by changing a few times revision_id to entity_id in the function relation_select_entity_get_relations.

Altered function:

function relation_select_entity_get_relations($entity_type, $entity_id, $relation_type){
  // Get the relation entities for this entity's relation type
  $relation_query = relation_query($entity_type, $entity_id);
  $relation_query->propertyCondition('relation_type', $relation_type);
  $relation_ids = array_keys($relation_query->execute());
  // Id there's no relation ids, we can return now as there won't be any relations
  if(!count($relation_ids)){return array();}
  // Now get the actual related entities
  $query = db_select('field_data_endpoints', 'fde');
  $query->fields('fde', array(
    'endpoints_entity_id',
    'endpoints_entity_type',
    'endpoints_r_index',
    'entity_id'                              
  ));
  $query->condition('fde.entity_id', $relation_ids, 'IN'); 
  $query->where('!(fde.endpoints_entity_type = :entity_type AND fde.endpoints_entity_id = :entity_id)', array(
    ':entity_type' => $entity_type,
    ':entity_id' => $entity_id
  ));
  $result = $query->execute();
  $relations = array();
  while($record = $result->fetchObject()){
    if(!array_key_exists($record->entity_id, $relations)){ 
      $relations[$record->entity_id] = array(  
        'relation_id' => $record->entity_id,
        'endpoints' => array()
      );
    }
    $relations[$record->entity_id]['endpoints'][$record->endpoints_r_index] = $record->endpoints_entity_type . ':' . $record->endpoints_entity_id;
  }
  return $relations;
}

Works fine for me. Maybe some testing is needed by other people.

chromix’s picture

This worked for me. Do we need a patch for this in order for it to be accepted?

chromix’s picture

StatusFileSize
new2.63 KB

Here's one just in case.

steveoliver’s picture

Status: Active » Closed (fixed)

Working support for relation fields was committed to Relation Select in 7.x-1.x at git commit 7c8988f. See #1645534: Add entity fields to relation select field widget. Marking closed.