Multiple input fields in table - drupal

Currently we are migrating our intranet from plone 2.5 to drupal 7. Everything works out pretty well except one problem we are facing with the cck module.
In plone we had one content type "application" which allowed our members to applicate for a specific project. There were many input fields for describing the required qualification from other projects like in the following "image".
project description
[ ][ ] + - up down
[ ][ ] + - up down
[ ][ ] + - up down
add new row
Our member had the possibility to mention an unlimited number of projects and associated descriptions.
So the problem is, i´m unable to do anything similiar in drupal 7.
I could definitely add an unlimited node reference field and an unlimited text field, but there would not be any kind of relationship between the two fields and the user would have to click "add another entry" twice.
Another option would be the use of the module http://drupal.org/project/tablefield but its not possible to use the first column as a node reference.
I´ve browsed through every cck module available and found nothing really helping, so now i hope you can help me!
Thank you

Have you tried the field collection module?
This helps you add a collection of fields as a single field.
So you could have 'Projects' as a "field collection" type field have unlimited number of values. You can then add the individual field like the Project name, description, etc. in the field collection.
This module is for D7.

New answer to an old question (but isn't that how Drupal usually works): you might want to try the Multifield module as an alternative to Field Collection or the other solutions posted here. It's meant for this type of problem.

The module Field group is creating this relation for you.

In Drupal 6 we can do this using Flexifield The project description page of flesifield says that similar functionality can be achieved in Drupal 7 using Combo Field. But I have never tried it though. It might worth giving a try.

For Drupal 8 you can also look into the Paragraphs Module for handling a multiple field with multiple inputs. Can be used for product properties, recipes and more advanced use case where a single field can behave like a content type.
There is also a module for Drupal 7 and Drupal 8 called Double field

Related

drupal 7, pre populate field values from previous data

My situation is, when I click to add new content of lets say type "project", I want the fields be prepopulated with last entered values.. Since there is more then 40 fields, i don't want to fill every field individually..
Thanks
Well the answer may not be so simple. The best way i can think of is to create a custom module, hook_form_alter the node-edit form and change the #default_value of the form fields/elements you care about.
So in the defualt_value attribute of this you could implement a custom function that brings the data you need or hardcode the values
use devel module in drupal it creates content manually for specific content type i think it useful 4 u

How to change entity language in bulk?

I have a site in drupal which is in spanish by default. Now I want to add the english translation. It has a lot of entities "producto" with undefined ('und') language. I want to mass assign the 'es' language to them. Before posting this question I have checked this other question How to change node languages in batches? but I'm unable to accomplish what I want. Let me explain:
a) I have tried Language Assignement but it last commit was 1 year ago and it has a critical bug that can lead to data loss (I reproduced the error too) I also tried with the patch from user barami but the data loss persists.
b) View Bulk Operations: I've tried it, but it does only update the field in database table "node". Not the other ones.
c) So I checked out how the drupal database works and created a sql script which also leads to data loss:
-- Step 1 Node lang
update node set language='es' where type='producto';
-- Step 2 body field
update field_data_body set language='es' where bundle='producto';
-- Step 3 Field comment vody
update field_data_comment_body set language='es' where bundle='comment_node_producto';
-- Step 4 For each field of producto, update language
update field_data_field_precio set language='es' where bundle='producto';
update field_revision_field_precio set language='es' where bundle='producto';
(...)
I have the following translation modules activated:
Internationalization, Block languages, Field translation, Menu translation, Multilingual content, Multilingual select, Synchronize translations, Taxonomy translation, Translation redirect, Translation sets
What Am I doing wrong with my sql script? Are there other plugins to accomplish what I want to do? Any suggestion will be appreciated Thanks!
Here's how I bulk set the language on my site:
Using Views Bulk Optimization, select all nodes you want to change, use the 'Change value' option and then change the value to language you want.
After you've done this, the field values will not appear when editing the nodes, so you need to run a script, e.g. UPDATE database.field_data_body SET language='en' WHERE bundle='page' (use your db name, field name, and bundle as appropriate).
IMPORTANT: If you have any custom url aliases, they will be overwritten with this approach, due to a problem with pathauto, but there's a work-around: first go to /admin/config/search/path/settings, and change the 'Update action' option to 'Do nothing. Leave the old alias intact.', then change this value back once you've run your Views Bulk Operations action.
Assuming you can make a view listing your entities, you can use the Views Bulk Operations module to do this. I just explained how to do this the other day for nodes on Drupal Answers.
Another solution would be to just execute the first SQL because I have discovered that the fields language must remain 'und'.
update node set language='es' where type='producto';

Drupal: Content type in database not in the list of content types in Structure>Content types

A while ago I created two content types: 'protocol' and 'protocol2'
They were a little different and I wasn't yet sure of which one suited my purposes best, so I tried out both and created some content of each. After a bit of testing I concluded that 'protocol2' was the one I was gonna use and that I wanted it to be called 'protocol' and not 'protocol2'. But I wanted to save the other version of the protocol content type so I taught I would simply swich their names.
So I tried swiching their names, but during this process something went wrong with the 'protocol2' content type that I wanted to use and it just disappeared. Or so I taught. Anyway I renamed 'protocol' to 'protocol1'(Name and Machine name). And recreated the one that disappeared. I gave it the name Protocol and tried to give it the machine name 'protocol' but this didn't work so I ended up having to name it protocol2 again.
I have now discovered that there is in the node_type table in the database actually a content type with the machine name 'protocol' which doesn't show up when I look in Structure>Content types on the page. Can I simply clear it from that table or is there some other more propper way to do it?
I have been using Organic groups, and had content type of type 'protocol' or 'protocol2' associated with some groups(I don't remember which). And I think it's screwing up one of the views on the group page. The list with the heading "Publish content to group" consist of "Post" and an empty list element. Where can I control this list? Isn't this supposed to be a view?
In the node_type table, make sure locked is 0 and disabled is 0 for all your "protocol" types. Change all their orig_type values to match their current type values. Clear the Drupal cache in admin/config/development/performance.
They should all now appear in your "Content types" list and you can work from there.
This is an active bug for Drupal 8, with the possibility of any patch being backported, under Drupal issue 515454.

Drupal 6 & Views 2 - DISTINCT field

I'm using the Feeds module to import lots of Feed Item nodes. Due to a malformed feed file, I'm getting lots of duplicates. I'm using a View to display these nodes, and need to be able to add a DISTINCT filter on the "Node: Post Date" field, so I only get 1 result for each post-date.
I will also look into tackling the problem at the source so to speak (I don't want to have all those duplicates in the first place), but this is an interesting issue in itself - I can't find a way to add a DISTINCT filter on a field other than the Node ID (which has it's own option in the View's Basic Settings box).
I found a great article on a good way to alter the SQL queries that are generated from views before they get executed: http://echodittolabs.org/blog/2010/06/group-views. I used this to basically suffix a GROUP BY clause to the end of the query (in a really nice, clean and versatile way).
As an aside, I also found a way to tackle the issue of importing lots of duplicate feed items, the details of which are here: http://drupal.org/node/661314#comment-3667228. It adopts quite an extreme approach (deleting all items before each update), but this is the only solution for some nasty malformed feeds.
I was holding out for some undiscovered feature of Views that let you do this, but I don't think there is one - maybe in the next version ;)
There are two option to solve this:\
apply this patch
OR
hook_views_query_alter => just paste
$query->distinct = 1;
$query->no_distinct = 'views_groupby';
I guess you have two options: either put some logic in the view template file to skip the duplicate items or implement hook_views_query_alter() to change the query used by the view, adding the DISTINCT clause.
We found this issue in drupal 6.x view - had 7 of 150 items duplicated one or twice. No idea why. Issue only appeared for anonymous users. Luckily, views 6.x.2.16 provides a 'distinct' setting under the basic settings, I set it to Yes and got rid of the duplicates.

Drupal Custom CCK field with multiple child fields

Is there a way of creating a composite field that can have multiple values, with each value having another group of composite values?
E.g. we want to have this structure at the end:
Group 1 (unlimited number of groups)
Child field (unlimited children for each group)
Child field
...
Group 2
Child field
Child field
...
...
Is this possible at all for a custom module that defines a CCK field? If so, can someone push me in the right direction?
this is a very know and debated issue in the drupal world.
this feature is called cck "multigroup" and it looks it's pretty difficult to implement.
there are a lot of posts in the drupal forum about this, i suggest you to start here:
http://drupal.org/node/494100
it's a kind of "hidden" feature in the cck module. looking in the module directory, you will find instructions here:
cck/modules/content_multigroup/README.txt
Edit: Ongoing work on the multigroup module has moved to the experimental
CCK 3.0 branch.
in the meantime you can try to deal with it using the flexifield module
(but it's kinda hackish, i won't use it in production)
I ended up creating my own "Cost/Product" CCK compound field based on this excellent tutorial with example modules: http://poplarware.com/es/articles/cck_field_module
I haven't figured out yet how to pull out a specific sub-field, such as cost, in Views. I only get the entire ": $" compound.
For Drupal 7+, you probably want to check out the Field collection module, or Field group if multiples aren't necessary.
This issue is pretty old, but I just happened across it. I would think the way to handle it for now would be with a second cck type for the children, and the groups as a node_reference field. So you'd have:
MasterType
group field
unlimited per node
each one, a reference to a ChildType node
ChildType
child field
unlimited per node

Resources