I just don't understand the way this module works.

If I create a node, I can add relation.
If I edit a node with relations, I can add/edit/remove relation.
If I edit a node with no relation, there is no relation field, so I just can't do anything.

I show in the readme.txt that I can create a link to add a relation to the node, but it's more simple to add the relation when I edit the node, just like when we create a node.

Do I miss something ?

Comments

gilles_c’s picture

In relation_select.module, function relation_select_field_widget_multiple_form.
There is condition to prevent to show the add-more button if there is no field. If I remove it, the button appear but I need to push the add button 2 times, the first relation don't work, but the second is ok.

 if($field_elements){
    $field_elements += array(
      '#field_name' => $field['field_name'],
      '#cardinality' => $field['cardinality'],
      '#title' => $title,
      '#required' => $instance['required'],
      '#description' => $description,
      '#prefix' => '<div id="' . $wrapper_id . '">',
      '#suffix' => '</div>',
      '#max_delta' => $max
    );
    // Add 'add more' button, if not working with a programmed form.
    if($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])){
      $field_elements['add_more'] = array(
        '#type' => 'submit',
        '#name' => strtr($id_prefix, '-', '_') . '_add_more',
        '#value' => t('Add another item'),
        '#attributes' => array(
          'class' => array(
            'field-add-more-submit'
          )
        ),
[...]
steveoliver’s picture

Errance,

I also encountered the issue where Relation Select fields were not showing up on the node edit page when no relation was previously set (when the field previously WAS showing up), along with the following error thrown:

EntityMalformedException: Missing bundle property on entity of type relation. in entity_extract_ids()

I've been doing a bunch of work with the fields and with patching the relation_select module, so I figured I messed something up.

I removed and added my Relation Select fields back, and they began to appear as expected--with or without relations selected in the field.

Alternatively, or first, you could try submitting the edit page for that Relation Select field, make sure you have a relation and view selected -- they may have changed/been removed in your development.

steveoliver’s picture

The behavior I'm still encountering is:

if relation select field settings: Number of values = Unlimited, no field appear.
else if relation select field settings Number of values = 1, one field appears.
else if relation select field settings Number of values = any other number (n), n-1 fields appear.

In other words: Unlimited = none; 1 = 1; N = N-1 fields.

Errance,

Can you confirm any similar behavior with field settings?

gilles_c’s picture

You're right.
The field appears if I select a number.
It's same as you say : Unlimited = none; 1 = 1; N = N-1 fields.

gilles_c’s picture

I made an update today with the last dev version & nothing change :(
I hope to find some time to have a look to this bug but this month it's hard.

gilles_c’s picture

Ok, I think I find the problem. When the number of value is unlimited, the max is 0. We need to set it to 1, so we always have a field.
I try to make a patch.

steveoliver’s picture

Thanks, Errance.
I haven't dug into it yet, but I don't think this patch approaches the problem. It seems to hack at the effects. I'll be giving Relation Select issues some more time next week. In the meantime, maybe see how the $max var is being used. Have you stepped through this code with a debugger?

jpstrikesback’s picture

Status: Closed (fixed) » Active

Also seeing this cardinality issue, trying to relate terms to each other (the return of synonyms, yaaaay)

steveoliver’s picture

Status: Active » Closed (fixed)

Fixed in 3ccc29e. Thanks, Errance.

jpstrikesback’s picture

Status: Active » Closed (fixed)

Working now. Thanks for your work here, this is great!

steveoliver’s picture

You're welcome. This is a cool module.