This module provides a field and widget for displaying entity lists. Add an entity list field to any fieldable entity to supply your content editors with a simple UI for configuring lists of entities.

Example: You want to create a block type (bean) that lists nodes. You create the bean and add an entity list field to your bean in the Manage Fields tab. You can configure the field instance to allow your content editors to view the entire widget, including dropdowns for entity type, bundle, view mode, terms, etc, or you can expose a smaller number of relevant inputs. For example, the content editor may need to adjust the bundle and number of items to display, but not the entity type, terms, etc, so we uncheck the box for "Show entity type input," "Show terms input," etc, in the config for this field instance.

This module may be appropriate when you want content editors to be able to modify a list from within the familiar add/edit form for the container entity. Config options for these lists will be more limited than what the Views UI provides, but are sufficient for a lot of use cases and provide a simpler UI.

Dependencies: Entity API (entity)

Project page: http://drupal.org/sandbox/arnoldbird/1938852

git clone http://git.drupal.org/sandbox/arnoldbird/1938852.git entity_list_field

Reviews of other projects:
http://drupal.org/node/1939794#comment-7165148 (multiple reviews)
http://drupal.org/node/1930332#comment-7161842 (multiple reviews)
http://drupal.org/node/1938538#comment-7161908
http://drupal.org/node/1909588#comment-7222078
http://drupal.org/node/1911756#comment-7239952
http://drupal.org/node/1945576#comment-7248012
http://drupal.org/node/1956202#comment-7258324
http://drupal.org/node/1963342#comment-7273322
http://drupal.org/node/1937066#comment-7273904

Comments

arnoldbird’s picture

Issue summary: View changes

Updating review bonus section.

klausi’s picture

Don't forget to add the "PAReview: review bonus" tag as indicated in #1410826: [META] Review bonus, otherwise you won't show up on my high priority list.

georgemastro’s picture

There should be a semicolon on line 54 in your ajax-pager.js file.
The git clone on your description above should be this git clone http://git.drupal.org/sandbox/arnoldbird/1938852.git entity_list_field

georgemastro’s picture

Status: Needs review » Needs work
georgemastro’s picture

Issue summary: View changes

Added future plans.

arnoldbird’s picture

Status: Needs work » Needs review

@georgemastro
Thanks. The issues you mentioned are now fixed.

arnoldbird’s picture

I would like feedback on the machine name. Should I stick with entity_list_field? It makes for long function names. I could use entlist_field or el_field. Something else?

Or I could go with something quirkier, like daryl. I googled the name E.L. Field and the first person that came up in the results was someone named daryl. But that name doesn't say anything about what the module does.

Unfortunately "elf" is taken.

tmctighe’s picture

Hey arnoldbird,

1. Pareview had brought up some errors, but I decided to check it before I submitted this and noticed you cleaned them all up, great job!

2. Your Project Page could use some work. You've got some of the good basics (dependencies, an example case) however some additional sections like Features, Similar Projects, and Documentation links would go a long way. A great read on this is at: http://drupal.org/node/997024

3. A Documentation Page would help a lot. This helps new users know how to use the module and can include any other useful information you might have for someone trying Entity List Field. Your README.txt already has most of this information. See #5 on this link: http://drupal.org/node/7765

You do a great job of meeting the Coding Standards. Overall your code is well written, clean, and safe.

Module duplication does not seem to be a problem either, since this is the only module I could find that does this type of functionality without using Views.

Edit: saw the your above post. In response: entlist_field could definitely work. I don't really have much of a better suggestion... I understand your thought on clashing with other names or just being awkward, however it does, often, seem like being verbose in drupal is not a bad thing.

arnoldbird’s picture

@tmctighe

Many thanks. I've made significant improvements to the project page, following your suggestions: http://drupal.org/sandbox/arnoldbird/1938852

I'm not so sure a documentation page is appropriate at this time. I'd rather people just dive in and start configuring lists. The module hopefully explains itself well enough... I think. Once I have merged the listclass branch, a small amount of developer documentation may be in order.

I think I will switch to entlist_field for the machine name when this project is approved.

arnoldbird’s picture

The main branch now uses a class to handle the list building for the formatter. Optionally, field instances can be configured to use a different class. There is a new "list class" field in the field settings. I'll add documentation in the next day or two.

klausi’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://ventral.org/pareview/httpgitdrupalorgsandboxarnoldbird1938852git

arnoldbird’s picture

Status: Needs work » Needs review

I've run it through the sniffer a number of times. How important is it to stick to 80 cols per line in the README? I will shorten the README lines if needed... I'm just not sure if it matters in that file. It seems inconvenient to do that during early development, when the README is changing often. Perhaps there is some automated tool that will do that for me?

The other two issues are things I'm aware of. One is a false positive, I believe, re: the doc blocks. My doc blocks appear to be fine, and variables are documented. The other error has to do with case in variable names in the class. If I'm not mistaken, all of the classes in the drupal core would "fail" that test :) My decisions re: case make sense to me. I use camelCase for the vars defined outside of functions in the class. I use underscores for the rest.

Thanks for reviewing the module, and please let me know if I'm wrong about any of the above.

arnoldbird’s picture

And I hope I don't sound like I'm shouting! Thanks again for reviewing this.

arnoldbird’s picture

Issue tags: +PAreview: review bonus

review bonus

dydave’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

Hi arnoldbird,

Thanks a lot for sharing this module and work on fixing previously reported issues above.
I have been following the discussion initially at A field for displaying a list of entities (on GDO) which lead me to this application.

Just tested the module at 15bf4ad and got an error probably coming from an incomplete find/replace for a file path:
See in entity_list_field.module, line 408:
<?php drupal_add_js(drupal_get_path('module', 'entity_list_field') . '/settings-form.js'); ?>
should probably be:
<?php drupal_add_js(drupal_get_path('module', 'entity_list_field') . '/widget-form.js'); ?>

That's all I could find so far from a testing standpoint.

Initially, I was curious to find out what module would really add that Views and related fields modules (EVA, View reference, Views Field View, Viewfield) couldn't do already and it seems indeed that it adds a very flexible (perhaps too flexible in some cases) user interface for admins to build custom lists of items. It would be kind of like a very simplified user interface for views attached to a field.
I can better understand the use case now, believe this could serve to some other developpers out there and wouldn't see any interest in opposing the Similar modules argument I initially had in mind.

However, I would still be curious to know if something like this could potentially be built as an additional layer to existing Views Field modules, mentioned above (for example, provide the parameters to a views field/views to load the corresponding list).

One last validation related advice would be for you to run the coding standards validation (PAReview) again, after you have committed your changes, to make sure you didn't introduce any new coding standards errors when you made the changes. After that, feel free to change the status back to needs review, that will save you one not so useful review from another user who would have simply told you about the coding errors mistakes (more back and forth = more time). This is something very common that happens to all of us (and just for one whitespace at the end of the line... the status is changed back to needs work again).

On top of all that, if you really wanted to do things the best way, I would recommend you copy paste some of the different items I listed/detailed above and make them tickets in your sandbox project tracker. Then, when you commit you will be able to include a ticket number in your log message, as it's being done with most standard contributed modules (Views, Panels, Search API, etc...).
This is not needed for the validation of the module, but think about its future and potential community of developpers that would greatly appreciate going through your documented work if they came to use this module. When the module is approved, the commits will be visible to users along with the issues and all that, which would really get your module to look like a real/serious one.

Obviously there is still more work needed on this module, so I allowed myself to set the status to needs work.

I would be glad to hear what you think about trying to work out a potential extension on top of an existing Views Field module.

Well done and I sincerely hope these comments help you improving this very nice module.
Cheers!

arnoldbird’s picture

Status: Needs work » Needs review

@DYDave

Thanks for catching the unecessary reference to the non-existent settings-form.js. I removed it.

Re: views, this module is more general. It so happens that in the base class I chose to use EntityFieldQuery for for the query, but you could potentially write a class that uses db_select, or maybe something that plugs into the API of other modules that access the database.

To put it another way, views is just one way to access the database, and it's not clear that it makes such overwhelming sense in this case that this module should focus on connecting to views only.

As for viewsfield, as a reference field, it does something very specific and different than this module, and it might be arbitrary for me to lump this module's code in with that one. That would be a move away from modularity. People who need a field for referencing views should use viewsfield, and those people in many cases would strongly prefer not to have a lot of other unrelated code in the module that performs a different function altogether.

It's conceivable that someone could write a views-specific widget that pops up a kind of configurable mini-views UI that plugs into the views module somehow, but I'm doing something more general here. Also, creating a view is often involving enough that visiting another module's interface is a trivial step to take... so the need for a configurable mini-views popup UI is debatable. That aside, for many use cases people might prefer the path this module takes. If someone wants to write that other module, I'm sure a lot of people would want to have a look, but that's a different project.

As for the code sniffer, in this case I did remember to run it before committing. The issues it picks up are false positives... and in the case of the camelCase the sniffer just isn't making the best decision, I don't think. Don't get me wrong, the code sniffer picked up dozens of real problems that I had to fix before I created this application post.

I can't quite decide if it's a good idea for me to move things to the issue tracker. It seems just as likely that that would be less convenient for people at this point, rather than more convenient. Anyone is welcome to post bugs, and if they want, they could reference the issues here. But for now that seems less convenient.

I'm changing this back to needs review, and hope that's appropriate. A developer documentation page is in order, but the class is simple enough and well-documented enough in the code that I wouldn't think that would be a blocker here.

arnoldbird’s picture

Status: Needs review » Needs work

I take it back. Developer docs are needed. I will change back to needs work.

arnoldbird’s picture

Status: Needs work » Needs review

I added some developer documentation at https://drupal.org/node/1942468
I link to it from the project page. As far as I know there are no outstanding issues in this thread at this time, so I am changing this to needs review.

arnoldbird’s picture

Issue summary: View changes

remove unecessary git args

arnoldbird’s picture

klausi’s picture

manual review:

  1. Only instance variables should use camel case, function parameters or local variables should use underscores. So no false positive from Coder Sniffer. See http://drupal.org/coding-standards#naming
  2. You have to use "/**" doxygen style function comments instead of "/*", so there is also no false positive from coder sniffer. See http://drupal.org/node/1354#functions
  3. This module looks like it has great overlap with Entity Views Attachments, please try to justify the differences on your project page. http://drupal.org/project/eva
  4. entity_list_field_field_schema(): do not duplicate hook documentation in the doc block.
  5. entity_list_field_field_schema(): descriptions for the columns would be very useful.
  6. entity_list_field_field_schema(): why is numitems a float, sounds like an integer?
  7. entity_list_field_field_widget_form(): do not use drupal_add_js() if you have a form at hand anyway, use the #attached property of the elements.
  8. "$msg = t($str, $args);": do not pass dynamic variables to t() as that cannot be found by translation extraction tools. Always pass string literals to t() where possible.

to be continued ...

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

entity_list_field_options_callback(): this is vulnerable to XSS exploits. I can prepare this form:

<html> 
<form action=http://sff15f74b3575343.s3.simplytest.me/entity_list_field/options method=post> 
<input name='el_key' value='b"><script>alert("XSS");</script>' type='hidden'>
<input type=submit>
</form> 
</html>

Then I'll place that on my site and let it auto-submit with Javascript - bang, you have arbitrary javascript executed from your site. You need to sanitize user provided text before printing, please read http://drupal.org/node/28984 again. This is a security blocker.

entity_list_field_pageturner_callback(): why do you write to $_GET? Please add a comment.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

arnoldbird’s picture

Issue tags: +PAreview: review bonus

Thanks. I have pushed fixes for all those issues.

The EVA module does not provide a widget, as this module does. Furthermore, EVA works with views only, provides a different workflow for content editors, and utilizes the views UI for configuring the query.

The base class for Entity List Field uses EFQ for the query, but anyone can override the getList() method if they want to build the list some other way. It is difficult to anticipate all the possibilities. Also, because the list is built in code, there are all sorts of things one might do in the programming related to the list.

EVA looks like a great module, and I should mention it in my readme and project page as an alternative. It appears it may even be possible to add some fields to a content type and use those fields to configure the view's behavior directly from the entity's add/edit form. This would at least partially achieve one of the goals of the Entity List Module -- keeping the content editor in the form for the entity, and not sending them off to the Views UI. However, there may be limitations as to what one could do with that approach. We can use fields to pass arguments to the view attachment to filter the list, but can we change the sorting? Can we change the number of items to display? Change the view mode? It appears the content editor would still have to visit the Views UI for these things.

In any case, EVA is a views-only module, and Entity List Field is more open-ended, but uses EFQ by default.

arnoldbird’s picture

Status: Needs work » Needs review
Issue tags: -PAreview: security

Removing the review bonus tag pending a security fix. Thanks for catching. I accidentally added the bonus tag back in my last post.

arnoldbird’s picture

Issue tags: -PAreview: review bonus

The security issue is fixed now.

arnoldbird’s picture

Issue summary: View changes

updating reviews

klausi’s picture

Issue tags: +PAreview: security

Please don't remove the security tag, we keep that for statistics and to show examples of security problems.

klausi’s picture

Issue summary: View changes

remove outdated content

arnoldbird’s picture

Priority: Normal » Major

I'm raising the issue priority because it has been 2+ weeks since this application has been set to "needs review."

arnoldbird’s picture

Issue summary: View changes

Adding a review link

arnoldbird’s picture

Issue summary: View changes

Adding a review link.

arnoldbird’s picture

Issue tags: +PAreview: review bonus

Adding the review bonus tag.

arnoldbird’s picture

Issue summary: View changes

Adding a review

klausi’s picture

Priority: Major » Normal
Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

manual review:

  1. entity_list_field_pageturner_callback(): this is vulnerable to unexpected code execution if you just take the class name out of a $_POST parameter. Sure, there must be a class in your Drupal installation that does something unexpected and has a getList() method. You need to make sure that the 'list class' is in a range of values that you know about and that are safe. This is a security blocker. This reminds me a bit of the unserialize exploit: http://heine.familiedeelstra.com/security/unserialize
  2. entity_list_field_field_widget_form(): do not use drupal_add_js() if you have a form at hand anyway, use the #attached property of the elements. Or does that not work.

But otherwise this looks pretty ready. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

arnoldbird’s picture

Status: Needs work » Needs review

Those two things are fixed now.

arnoldbird’s picture

Issue summary: View changes

adding another review

arnoldbird’s picture

Issue summary: View changes

adding another review

arnoldbird’s picture

Issue tags: +PAreview: review bonus

Adding review bonus

nsuit’s picture

Status: Needs review » Reviewed & tested by the community
klausi’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, arnoldbird!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

arnoldbird’s picture

Thanks everyone for reviewing the module.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

add another review