Summary

Field Collection provides a way to reuse sets of fields by defining an entity whose purpose is to have fields attached to it. Field Collection is very widely used in Drupal 7 builds. An alpha version of 8.x-1.0 exists and is working on Drupal 8.1.

Project URL

https://www.drupal.org/project/field_collection

Where's the code?

https://www.drupal.org/project/field_collection

ETA

Alpha is available. ETA for a full release is unknown.

Dependencies

The Drupal 7 version of Field Collection depended on Entity API. All of Entity API's functionality is in Drupal 8 core, so the straight Drupal 8.x-1.x port has no additional dependencies (assuming its architecture isn't changing much).

The 8.x-2.x branch is rearchitected to depend on core's Entity Reference system and the Inline Entity Form module

Who's doing the port?

fago, larowlan, jmuzz and tim.plunkett are the main committers to 8.x-1.x. You can get some idea of when and how much each were involved up to October 2015 in the commit list on #1443960: Field Collection for Drupal 8 .

Currently tedbow is leading the work on 8.x-2.x, but is looking for help.

What help do they need?

Anyone familiar with Inline Entity Form, Field Widgets, and Field Formatters.

D8 Roadmap

TBD

Background/Reference Info

#1443960: Field Collection for Drupal 8

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Status: Active » Needs review
webchick’s picture

As of right now, both the 8.x dev release and the sandbox appear to be in sync. Filed #2603054: Close this sandbox and move development to Field Collection queue? to see about consolidating.

PratikshaD’s picture

Not able to add value for field in field Collection Drupal 8

I have done custom code to add value for field but its throwing error which is given below.

Code is given below-
$mynode = node_load(983);
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_test'));
$field_collection_item->field_end_date[LANGUAGE_NONE][0]['value'] = "20-20-2015";
$field_collection_item->field_account_name[LANGUAGE_NONE][0]['value'] = "DCX";

// Save field collection item
$field_collection_item->setHostEntity($mynode);
$field_collection_item->save(TRUE);

I got this Error-

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: Unable to get a value with a non-numeric delta in a list. in Drupal\Core\TypedData\Plugin\DataType\ItemList->get() (line 103 of core\lib\Drupal\Core\TypedData\Plugin\DataType\ItemList.php).

Drupal\Core\TypedData\Plugin\DataType\ItemList->offsetGet('LANGUAGE_NONE')
csvimport_import_batch_processing(Array, Array)
call_user_func_array('csvimport_import_batch_processing', Array)
_batch_process(Array)
_batch_progress_page()
_batch_page(Object)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

webchick’s picture

Hey there! A much better place for this bug report would be over in the field collection issue queue. This issue's simply tracking its current D8 porting status.

PratikshaD’s picture

This is not very much clear to me could you please elaborate.
While creating new entity for field Collection in D8, I am getting error for langcode its should be in numeric format:
"InvalidArgumentException: Unable to get a value with a non-numeric delta in a list. in Drupal\Core\TypedData\Plugin\DataType\ItemList->get() (line 103 of core\lib\Drupal\Core\TypedData\Plugin\DataType\ItemList.php)."

Below is the code snippet :
$mynode = node_load(983);
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_test'));
$field_collection_item->field_end_date[LANGUAGE_NONE][0]['value'] = "20-20-2015";
$field_collection_item->field_account_name[LANGUAGE_NONE][0]['value'] = "DCX";

// Save field collection item
$field_collection_item->setHostEntity($mynode);
$field_collection_item->save(TRUE);

Please suggest...

webchick’s picture

Yes, please search https://www.drupal.org/project/issues/field_collection for your issue. If it's not found, report it over there with the "Create new issue" link.

penyaskito’s picture

Issue summary: View changes
penyaskito’s picture

Latest commit on 8.x-1.x branch in the project itself is more recent than the sandbox, so editing summary.

tim.plunkett’s picture

Issue summary: View changes

After several days of discussion, we've decided to rewrite the module on top of Inline Entity Form. This will become the 8.x-2.x branch.
The 8.x-1.x branch is still open for patches, as it intends to mirror the architecture of the D7 version.

I'm happy to commit patches to both versions while they are under development.

tim.plunkett’s picture

Status: Needs review » Needs work
jibran’s picture

Is there an issue for that which we can follow? Are we going to use ER field for field_collection_item? See #2509254: Field collection fields should extend entity reference fields for more details.

larowlan’s picture

+1 to 10 and 12

Sam152’s picture

Paragraphs might be worth looking at. I believe that was built on top of entity_reference_revisions for the field type/widget. Might help consolidate efforts and save time.

colepacak’s picture

I know the ETA is still unknown but do you guys have a ballpark?

My team is working on a D8 site that would ideally use Field Collection but I'm trying to figure out whether to move forward without it.

heddn’s picture

@colepacak, there is also paragraphs and custom entities that would work. the drupal console just had land everything you need for a custom bundle-able entity.

tim.plunkett’s picture

Issue summary: View changes
jmuzz’s picture

There's an alpha for field collection 8.x-1.x now that I'd say is pretty solid. I've been working on it on and off for the last couple of years. I've also been maintaining the drupal 7 version of the module during that time.

I never saw the discussion about starting over to make a rewrite. I don't think there was an issue about it.

Given that it's not really a new version of the module but a total rewrite, it would make more sense to classify it as a competitor to field collections like complex fields or multifield, both of which were talked about in the fieldable fields in core issue.

People seem to have a love/hate relationship with field collections. Everybody uses it but everybody wishes there was something better. I am all for new ideas but for the sake of fairness they should be on an even playfield, and given the amount of work that has already gone into field collection 8.x-1.x and where it is compared to the other versions it would be a waste to try to convince people that it's obsolete.

I think 8.x-2.x should be moved out to a separate project. If it ends up more useful then field collection people will switch to it. I don't know who all was involved in the days of discussions @tim.plunkett mentions, but if they really do want to start over from scratch they should aim to make something that can stand on its own like the developers of multifield and complex field are trying to do.

jmuzz’s picture

Issue summary: View changes
jmuzz’s picture

Status: Needs work » Needs review
asibona’s picture

I'm trying to porting field_permission module to drupal 8.
(Road Map -> https://www.drupal.org/node/2196303)
I realized this feature is lacking [getOwnerId()], do I have to do a special check to field_collection or can you implement this

/**
* Get entity Author id.
*/
public function getOwnerId() {
return $this->getHost()->getOwnerId();
}

in FieldCollectionItem.php

Thanks.
Ale.

jmuzz’s picture

Hi @asibona.

I made a separate issue for your request.

#2734551: Field permission support for Drupal 8