The problem occurs when you use field collections with the hidden widget (you don't want to embed the form on the edit page). But that means that users cannot change the ordering of items in a multiple field collection field. So one solution would be to introduce a new widget that provides a listing on the edit page with the usual drag & drop table order mechanism. It could display the field collection items as usual with edit/delete links.
Original report by Adam S
A resume will have the most resent education or job experience listed first or at the top. When a new educational experience is added to eRecruiter it is added to the bottom. Even then the user might want to insert an edited education experience. So there needs to be a way to control the delta of items.
Comment | File | Size | Author |
---|---|---|---|
#20 | resume.png | 62.95 KB | kaizerking |
#17 | rearrange-field-collections.png | 22.63 KB | Adam S |
Comments
Comment #1
Adam S CreditAttribution: Adam S commentedPerhaps letting the users determine the order of the field collection item list isn't necessary. It would be better to render the fields based on the date stamp time with the large date number being listed first. Also, what about people who need to put present as a date meaning that they still work at a place?
Comment #2
Adam S CreditAttribution: Adam S commentedI'm marking this critical because every resume puts the most recent education or job experience in decending order by date. This problem is preventing me from lunching the website.
Comment #3
Adam S CreditAttribution: Adam S commentedAfter a day of using Google and StackExchange to find out how to sort arrays with PHP, I came up with this code. I know it needs refactoring. I'm sure it probably isn't the best way to handle this problem but it seems to do the job.
Comment #4
kaizerking CreditAttribution: kaizerking commentedHi Adams , I have been searching for this feature, Where to put this code please, I am new bee, dumb like a rock
Comment #5
Adam S CreditAttribution: Adam S commentedThis isn't tested and I don't really know PHP -- I was just making a guess and it seems to work. I placed it in a module called helper.module that I use to host misc code that I don't put in template.php. To make a module you need a folder in sites/all/modules called helper. In that there needs to be two files, helper.info and helper.module.
helper.info should have these three lines of code:
Then place the above function inside of helper.module (that is all the code placed in it). The info file shouldn't have
<?php
tag but the helper.module file should start with an opening<?php
but not close with one.Comment #6
kaizerking CreditAttribution: kaizerking commentedThanks Adams ,
I have checked your site , it is amazingly wonderful, Wish I could make a site like yours, especially I like the theme, simple and sober and no nonsense
am also not a coder.just trying to attach bits and pieces and make site
I have created a module called "date range overlap" with the given code, It isn't working
What I am expecting is , each time I add an experience,
1.It should prevent me from adding a conflicting date range,
2.It should re order the view according to descending sort order
Any suggestion or idea please?
Comment #7
Adam S CreditAttribution: Adam S commentedThe first one will require quite a bit of custom code perhaps you might want to hire someone to do that. Keep in mind that for almost all application this wouldn't work as people can work two jobs are go to summer school or overseas study while still enrolled in a school.
We will need a developer to implement the code for the distribution.
Comment #8
kaizerking CreditAttribution: kaizerking commentedYou are right, I am thinking too perfectionist and idealistic way, and not taking in to consideration the practical scenario.
Comment #9
klausiclearly a field collection issue.
Comment #10
tim.plunkettThere is no such thing as a critical feature request.
Can you update the title and the issue summary? It is eRecruiter specific, which means absolutely nothing to me. Please mark back to active when you do.
Comment #11
kaizerking CreditAttribution: kaizerking commentedThe issue has been in general demand for a long time pl refer:http://drupal.org/node/135711
I feel it is supposed to be Date module feature, who wants to take ownership depends on requirement.
Because the trigger should be the "collect end date" and "required",and if it is "multi value field" which should call function form alter( i don't know if that's what done to get new options), make form - new options-
Dates overlap
1. "Allow Dates over lap" (with a warning to user"),-Default
2. "Prevent dates overlap" and
Sort order or Order by:
1." do not sort"
2. "Ascending
3. "Descending".
Implementing "current status": this is very tricky thing because many users may not be working currently to say "current", Obviously if he is working he wont visit a job site, it may look a silly logic, but true.
Also logically, a duration calculation also can be part of this
1. duration for single value field
2. Multi value field (sum of single value durations)
3. field collection fields
Settings:Duration in years,months,weeks, days, Hours , Minutes, Seconds
Comment #12
Adam S CreditAttribution: Adam S commentedThis feature request was made in context of a distribution profile that I could not put online because field collections could not be sorted. I'm still not sure why this issue was moved as it is specific to listing order of job or education history of a job board website.
Of course, being able to sort field collections is a wider issue but my experience is that it is solved using a drag and drop mechanism on the edit form.
Comment #13
Adam S CreditAttribution: Adam S commentedHow about adding a configuration setting to the field collection item being added to the parent enitity that allows of using another field to use as the sort?
Comment #14
klausiSorry for the confusion. As far as I can see the problem occurs when you use field collections with the hidden widget (you don't want to embed the form on the edit page). But that means that users cannot change the ordering of items in a multiple field collection field. So one solution would be to introduce a new widget that provides a listing on the edit page with the usual drag & drop table order mechanism. It could display the field collection items as usual with edit/delete links.
Comment #14.0
klausiadded field collection specific problem description
Comment #15
kaizerking CreditAttribution: kaizerking commentedAdam, this code worked for me, how ever, on first creation of an experience I am getting this"Notice: Undefined index: und in helper_entity_presave() (line 31 of /hsphere/local/home/......./sites/all/modules/helper/helper.module)."
Comment #16
Adam S CreditAttribution: Adam S commentedSince users in the case of eRecruiter do not have the option to use the edit page, perhaps, another more elegant version of this idea is to include a 'rearrange' link on each field-collection group next to the 'add' link which doesn't load the entire node edit form but a form that allows the user to drag 'n drop each field-collection within the group.
Comment #17
Adam S CreditAttribution: Adam S commentedHere is a screen caption of what the widget link for a rearrange form would look like.
Comment #18
Adam S CreditAttribution: Adam S commented@kaizerking
We should open this issue again in the eRecruiter queue.
However, the problem here is that if there isn't an original entity because the first one was just created there isn't any reason to sort it. So line 31 should be something like
if (!empty($entity->field_resume_education) && !empty($entity->original->field_resume_education)){
orif (!empty($entity->field_resume_xp) && !empty($entity->original->field_resume_xp)){
.Comment #19
kaizerking CreditAttribution: kaizerking commentedOk, But as of now the code is working , i think we should suppress message, any idea on how to ?
Comment #20
kaizerking CreditAttribution: kaizerking commentedcalculating the duration worked out using the computed field
I have requirement to
1.sum up all the durations in a work experience field collection in resume,
help me please pl.
2. Calculate the duration from the oldest start date to Date Now()
help please
have look at screen shot
Comment #21
Adam S CreditAttribution: Adam S commented@kaizerking
This is a very esoteric problem and has little to do with Field collection so I'm not sure if it belongs here. This is more appropriately asked in drupal.org forums or on drupal.stackexchange.com. This issue thread is now about how to order Field collections in general.
Comment #22
g089h515r806 CreditAttribution: g089h515r806 commentedi have created a module "Field Collection Views Formatter", http://drupal.org/project/field_collection_views
which provide a replace solution for this issue.
Test it.
Comment #23
tim.plunkettIf you want to edit the field_collection on the edit form, use the Embedded widget.
I guess you can just hook_form_alter and set the inputs to disabled if you really wanted to.
Comment #23.0
tim.plunkettfixed username
Comment #24
rogical CreditAttribution: rogical commentedI have many field collection fields in a node, about 8 field collection(within 5 fields each).
It's tooo heavy to edit those field collection fields together in a node form, so I use the hidden widget, add field collection items on the node view.
But too sad can't order the field collection item, I think this feature is quite useful and need to sort the item in a standalone page for a field collection field.
Comment #25
8bitplateau CreditAttribution: 8bitplateau commentedI think this would be better handled as a separate module that gives you options in the Fields UI for the field collection for how you want to handle the Sorting, eg, Choose a Field to sort by and order ( ASC etc ). That would be great and isn't really this modules problem.
However, I also wanted to sort a Field Collections delta according to a time field within it for a task schedule app, and here is the code I used.
Comment #26
drupix#25 worked like a charm.
Thanks.