While creating the Bundles for Neologism module, I was trying to name the install fields in a way they could be re-used, since there seemed to be a lot of similar instances. But I figured out that one bundle can not have multiple instances of the same field, since the following error shows up :
FieldException: Attempt to create an instance of field neologism_text on bundle property that already has an instance of that field. in field_create_instance() (line 488 of /Applications/MAMP/htdocs/gsoc/modules/field/field.crud.inc).
Here, I tried to create two instances of the installed field "neologism_text" in the bundle "property".
Am I missing out on some attribute in the instances which could prevent this clash?
For now, I installed separate fields for each instance that I would am using and everything works fine.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | js-1165740-14.patch | 32.01 KB | mayankkandpal |
| #12 | 1165740-12-References.patch | 27.38 KB | mayankkandpal |
| #7 | 1165740-7-create-display.patch | 7.82 KB | mayankkandpal |
| #5 | 1165740-5-create-bundles.patch | 17.19 KB | mayankkandpal |
Comments
Comment #1
cygri commentedHm, I'm trying to understand. Why would there be two instances of "neologism_text" on "property"? What does "neologism_text" even mean here? Shouldn't you have fields like "neologism_title", "neologism_comment", "neologism_superclasses" and so on?
Comment #2
mayankkandpal commentedThe field instances are called property_comment, property_title etc.
But we need to install the fields first and then create their instances.
So if I create neologism_text, I thought I should be able to use it to create two instances required for the property bundle as in, say, property_title and property_comment. But it doesnt seem to work that way. So now I have created separate fields for each instance.
Comment #3
cygri commentedI'm not sure how this works, but I think the idea is that you create a neologism_comment field, and then you have field instances class_comment and property_comment. So you can re-use a single "comment" field in several bundles.
Comment #4
mayankkandpal commentedYes, it will work this way, I tried it out.
Comment #5
mayankkandpal commentedPatch for creating bundles for Vocabulary, Class and Property. Now we can remove the 6.x branch as discussed on #1166054: Clean up releases of Neologism on drupal.org
Remaining Issues :
1. Node reference type fields not created yet. It is unclear whether I should use the References module (http://drupal.org/project/references) or the Relation module (http://drupal.org/project/Relation). Probably, we could discuss over their merits and demerits over here.
2. Bundles not grouped yet.
3. Fields left to be add :
Vocabulary:
add js for dynamically generating default Namespace URI
add text box for custom Namespace URI
Class:
node reference fields
Property:
node reference fields
4. not yet added display settings
Comment #6
mayankkandpal commentedComment #7
mayankkandpal commentedPatch for adding display settings to the three bundles.
Apply this patch after the above #5: Support patch.
Comment #8
Anonymous (not verified) commentedI spoke with scor over Skype. We both agree that you should use References right now. References will be deprecated at some point, but are in much better shape currently. Also, since we're currently using nodes, the Node Reference module in References project fits.
Comment #9
scor commented@mayank unless there is a good reason to do otherwise, you should try to build on the same patch instead of posting separate patches which depend on each other... it's less confusing that way and easier to review (even if it makes the patch bigger).
in #5
should just be
array keys don't matter in this context, PHP will add internally then when needed.
Comment #10
mayankkandpal commented@Lin
Thanks, References it is then !
@scor
Will keep these things in mind in future. Thanks :)
Comment #11
mayankkandpal commentedI am facing an issue with the user_reference field, and have asked the References module developers for support #1171236: Problem while using the user_reference field in my bundle.
Comment #12
mayankkandpal commentedPatch for creating user_reference and node_reference fields. Minor changes to display settings and UI.
Does not depend on previous patches, apply to 7.x-2.x
Comment #13
mayankkandpal commentedHowever, the issue with the user_reference field stated in comment #11 (http://drupal.org/comment/reply/1165740#comment-4526388) still remains, since none of the Maintainers of References has replied yet.
Comment #14
mayankkandpal commentedPatch.
Added Javascript and modified Entity fields.
Apply to 7.x-2.x
Unfortunately the problem with user_reference field has'nt been solved yet since nobody replied on Drupal stack-exchange, Drupal support or the References issue queue.
Comment #15
mayankkandpal commentedOk finally figured out the user_reference issue.
Did the following for a working user_reference field:
and pasted all the missing fields into field and instance definitions. Couldnt figure out a better way !
Working snippet for future reference :
Field definition
Instance definition
Comment #16
mayankkandpal commentedDevelopment Continued at #1182526: [D7 Port] Registering vocabulary with evoc schema
Comment #17
mayankkandpal commentedversion changed to 7.x