Sử dụng field trong Drupal: Inline Entity Form Vs Field Collection

Sử dụng field trong Drupal: Inline Entity Form Vs Field Collection

My last post on field collections involved revisioning with Workbench Moderation and the issues faced. Since then the module has been developed further, but I've also come across a potential replacement: Inline Entity Form. Below is a short comparison of the two modules.

>> Hướng dẫn tạo Drupal Views Relationships và Entity References phức tạp

>> Phương pháp Responsive Images trong Drupal 7 với Picture Module

In this example I'll be adding a page with the ability to add a list of pets. The available fields will be the pet name, image, type (term reference) and a long text description field. 

Creating the field

IEF

Sử dụng field trong Drupal: Inline Entity Form Vs Field Collection

Before you can add the field you would need to create the entity you want to reference (in this case a node). After creating the 'Pet' node and needed fields you can then add the entity reference field to the page. When doing so you can select Inline Entity Form as the widget and will take you through the normal entity reference field options with the addition of 3 options (pictured). 

FC

When adding a field collection it is selected as the field type, with options to hide empty items and display a set number, or unlimited items. Once added you would then need to navigate to structure > field collections and add the fields to the created FC.

Adding the content

IEF

When creating a new page you're unable to view the needed fields until the 'add new node' button is clicked. Once done the fields appear as you would expect them to.

Required validation functions as you'd expect - unable to save the node as a whole until required fields are completed.

If you've opted to allow multiple nodes to be added the option for the user to do so doesn't appear until the 'create node' button is clicked and the added node saved. Once saved the added nodes appear in a list (seen below)

FC

Adding a new node with field collections is a little more user friendly, allowing them to immediately see the fields, and the option to add more items as needed.

As with IEF, validation functions as expected.

Viewing the node

IEF & FC

Both of these function as you'd expect, displaying according to the 'manage display' settings of either the node or the field collection as needed.

Workbench Moderation

IEF

Out of the box this sadly doesn't function, when creating a new draft and updating the existing linked nodes they're published when the new draft is created. There is an issue logged but with no recent updates you're forced to look elsewhere for a solution. I tried playing with the entityreference workbench sandbox module but wasn't successful.

The 'workaround' for this is to enable revisioning and moderation for the node type referenced and then publish them separately, this would mean that you're still unable to view the updated reference node within the page.

FC

Working with beta7 this functions out of the box. Adding a new draft and modifying the FC values doesn't publish them until the whole node is published and you're able to view the draft content inline with the rest of the node.

The result of this can be seen below, where the top name/image is the Inline Entity Form, and the lower name/image is the field collection. The first showing the published page, and second showing the draft page.

The Result

The result is that Field Collections has come a long way, and while it still has issues it is definitely improving. Inline Entity Form may be able to provide the same moderation support as FC one day, but the ability to moderate sections of content on a page separately to the rest of the page may be useful depending on your requirements (often promoted alongside commerce/product solutions). This was just a brief test and demo and there may be issues with other functionality such as search (SOLR), multi lingual etc. As with most Drupal modules, you'll need to weigh up the pros and cons before deciding what is best for you and your project. 

With thanks to James M for introducing me to Inline Entity Form.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Giới thiệu sách Drupal 7 - Multi-sites Drupal Book

Giới thiệu sách Drupal 7 - Multi-sites Drupal Book

It took me some days to actually get started on this and start writing. As some of you already know, Packt has given me the Drupal 7 - Multi-sites Configuration book to review. 

Google Panda - Thuật toán cho thứ hạng thật?

Google Panda - Thuật toán cho thứ hạng thật?

Mới đây, Google đã bản cập nhật một thành phần quan trọng về cách xếp thứ hạng các trang web đã ảnh hưởng tới 12% kết quả tìm kiếm và làm giảm số lượng truy cập của rất nhiều trang.

Tạo album ảnh độc đáo trên Facebook bằng LifePix

Tạo album ảnh độc đáo trên Facebook bằng LifePix

Sao chỉ đăng những bức ảnh đơn điệu lên Facebook, trong khi đó bạn lại có thể làm nhiều hơn thế với LifePix?

Công ty diệt chuột T&C

 

Diet con trung