Hi everyone

Wow this is an amazing module!

would be awsome to have it integrated with the field_collection module :)

Comments

e2thex’s picture

@Ciprian Oancia

Do you know what that would entail?

Ciprian Oancia’s picture

@e2thex no, but it woulve fit very well for an reseller website im building.

chrisroditis’s picture

Category: feature » bug

Hi and thanks for the great module!
I came up into problems integrating this module with field_collection, I will try to give an short example:

Let's say we have a "field collection" field called "field_location" which consists of two normal fields "field_location_name" (a text field) and "field_location_hotels" (a multiple-value node reference field).
Now if we use nodeconnect to add hotels to the "field_location_hotels" field, two problems arise:

In "nodeconnect_add_edit_button_submit", the line $language = $form[$field]['#language']; (line 70)
gives us a warning, because field_location_hotels is not stored directly in the $form array (as $form['field_location_hotels'] ), but is instead stored in $form['field_location']['und'][0]['field_location_hotels']

The second problem that arises from this situation is in "nodeconnect_return_node_form_alter", line 160 which is the same problem as above with the language, and finally line 166, nodeconnect adds the newly created nid into $form_state['field_location_hotels']['und'][0]['nid'] but as before the actual field value is expected at $form_state['field_location']['und'][0]['field_location_hotels']['und'][0]['nid']

Any ideas how field_collection fields should be dealt with? The only clue I guess would help is checking for $form[$field]['und'][0]['#entity_type'] == 'field_collection_item' or scanning the $form tree to find $field

e2thex’s picture

Ok so I think the problem here is that we should be not looking at $form[$field] but building this from the #parents tag.

That way we find the correct field to update.

@christopher_skauss do you think you could check and see if that is possible? I do not think i will have time to deep dive until late next week

chrisroditis’s picture

I've managed to bypass this with an ugly recursive array scan, but I'll try to squeeze sometime to look into #parents, sounds reasonable unless field collection did any dirty tricks with that too

rp7’s picture

subscribe

jdufaur’s picture

subscribe

bryancasler’s picture

@e2thex How much time investment are we taking to get this integration working?

dtarc’s picture

See http://drupal.org/node/1217150 for a similar issue that was solved for noderefcreate.

bryancasler’s picture

Not sure if it's this simple, but in the dev release this is all the code that references "$form_state"

nodeconnect.module

37 /*
38  * implements of hook_field_attache_form()
39 */
40 function nodeconnect_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
41   foreach (_nodeconnect_get_ref_fields() as $field_name => $field) {
42     if (isset($form[$field_name])) {
43       nodeconnect_include_form();
44      _nodeconnect_field_attach_form($entity_type, $entity, $form, $form_state, $langcode, $field_name, $field);
45     }
46   }
47 }
66 function nodeconnect_form_node_form_alter(&$form, &$form_state, $form_id) {
67   $child = isset($_REQUEST['child']);
68
69   // We can get the cid two different ways
70   // first we try the $_REQUEST param.  if we do not getting it from there we try
71   // the arg(3) if we are on a add form.  Also if we are on an add form we know that
72   // we are a child page.
73   if (
74        (isset($_REQUEST['build_cache_id']) && ($cid = $_REQUEST['build_cache_id']) ) ||
75        ((arg(1) == 'add') && ($cid = arg(3)) && $child = TRUE)
76       ) {
77     $cache = cache_get($cid);
78     nodeconnect_include_form();
79     if ($child) {
80       $form_state['#nodeconnect_child_form'] = $cache;
87     }
82     if (isset($_REQUEST['return'])) {
83       unset($_REQUEST['build_cache_id']);
84       nodeconnect_return_node_form_alter($form, $form_state, $form_id, $cid, $cache);
85     }
86   }
87   // If this for is a child form lets add alter for that purpose
88   // Note that we are doing this here becuase when we retrun to a form it gets rebuild
89   // so this will get cuaght in the rebuild
90   if (isset($form_state['#nodeconnect_child_form'])) {
91     $cache = $form_state['#nodeconnect_child_form'];
92     module_load_include('inc', 'nodeconnect', 'nodeconnect.form');
93     nodeconnect_child_node_form_alter($form, $form_state, $form_id, $cache->cid, $cache);
94   }
95 }
bryancasler’s picture

deleted