Tos Web Developer provides insights, tutorials, and advice around topics including content strategy, design, Drupal Development, Drupal Custom Module Development, Drupal 8 Custom themes, PHP, Server, Twig, and more




Field collection can be used in case a field has sub-fields. For e.g Name can have sub-fields such as First Name, Middle Name, and Last Name. There might be a requirement of loading field collection items programmatically. It can be done in following way:

 $fieldCollection = \Drupal\field_collection\Entity\FieldCollectionItem::load($fieldCollectionId);  
 $firstName = $fieldCollection->get('field_first_name')->getValue();  

It is better to use Paragraph module instead of using field collection, because it has better features and is being well maintained.

No comments:

Post a Comment

| Designed And Blog Post by www.toswebdeveloper.com