Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
looking for a way of keeping field defintions in code (or moving single fields from one installation to another), I was looking for a way of exporting and importing fields and instances. The only useful module I found was Bundle Copy, but it doesn't allow to export only fields, without the underlying entity (at least I wasn't able to figure out how).
As I really needed this I coded a quick version myself: Field Export (sandbox). Then I found your module and thought it might be worth the trouble of integrating this functionality.
I would be glad to give a helping hand, providing patches, ...
Comment | File | Size | Author |
---|---|---|---|
#6 | field_tools-export-1859388_6.patch | 17.1 KB | berliner |
#4 | field_tools-export-1859388_1.patch | 16.62 KB | berliner |
#4 | field_tools-screenshot-duplicated-tabs.png | 19.29 KB | berliner |
#2 | field_tools-export-1859388.patch | 16.86 KB | berliner |
Comments
Comment #1
joachim CreditAttribution: joachim commentedThis is something we could add:
- to each field as an export tab
- to the entity type admin as in import tab
Patches gratefully accepted! :)
Comment #2
berliner CreditAttribution: berliner commentedPatch adds:
Comment #3
joachim CreditAttribution: joachim commentedThanks for the patch! Sorry it's taken me a while to look at it -- big patches are daunting, and I was hoping other users would give it a try too.
This is just a first-pass eyeball review. There are quite a few minor problems that need fixing. Sorry if this seems like a lot of nitpicking, but as a maintainer, I need to keep the code in the module in a form that is readable and understandable. Hence I'm stickler for Drupal coding standards -- please do take some time to familiarize yourself with them :)
Can you check the formatting of your docblocks please?
- first line needs a full stop.
- @param lines need a description
- no @return needed if there is no return
Please trim whitespace before rolling a patch. Also, this blank line shouldn't be here anyway.
Why would this parameter sometimes be an object and sometimes not? The @param docs need to explain this.
What is this testing?
No need for this blank line.
Needs a docblock -- though you can skip the @params since they are standard.
What is this testing?
Shouldn't this set an error message too?
This needs to be explained.
I'm not terribly keen on this. It makes forms harder to understand. Do we really need it? How many times is it used? How many times is the form array it returns tweaked a bit by the caller?
Use hook_form_FORM_ID_alter() here.
What is this testing?
Comment #4
berliner CreditAttribution: berliner commentedThanks for the review. I always thought I was picky with coding standards :-)
I have rerolled the patch with added comments and updated doc blocks.
This is used 4 times and it makes sense to me as it respects the DRY principle.
One thing I changed in the patch though is the menu position of the "Export fields" / "Import fields" menu items which are now local tasks underneath the "manage fields" page. I realized that they are duplicated when comments are enabled, because comments are also fieldable, see attached screenshot. This applies to the "clone" menu items as well, but that would be another topic.
Comment #5
interdruper CreditAttribution: interdruper commentedFirst of all, thanks for this useful patch.
In my tests, I found the following error when trying to Export the fields from an entity created with ECK:
Notice: Trying to get property of non-object in field_tools_bundle_export_form() (line 471 of ...\field_tools.admin.inc).
This is the line 471:
The same error appears when trying to Export the fields from any Field Collection.
In these cases, $bundle is just a string, not an array, the opposite that happens in Content Types.
Comment #6
berliner CreditAttribution: berliner commentedThanks for the feedback. I corrected the patch to be compatible with eck and field collection.
Reverting the category to "feature request" because this is still a feature request with a patch in work.
Comment #7
joachim CreditAttribution: joachim commentedCommitted a modified version of the patch with a few tweaks:
- Fixed button label on export form.
- Added CTools as dependency.
- Moved menu items under Tools tab.
- Spacing and comments formatting.
git commit -m "Issue #1859388 by berliner: Added tools for field import / export." --author="berliner "
Thanks!
Comment #8
berliner CreditAttribution: berliner commentedCool! You can add that functionality to the list on the project page as well.
Thanks for maintaing this module!
Comment #9
joachim CreditAttribution: joachim commented> You can add that functionality to the list on the project page as well.
Already done :)
You're welcome! Thanks again for all your work on this new feature.
Comment #11
R-H CreditAttribution: R-H commentedI just used the import feature. Thank you for saving me hours of recreating fields!
Comment #12
stpaultim CreditAttribution: stpaultim as a volunteer commentedI'm looking all over for the "import feature" and can't find where this happens. The "export" portion is pretty clear. Is there a UI option for importing the field? If so, where do I find it?
Comment #13
Ollie222 CreditAttribution: Ollie222 commented@stpaultim
I've come across the same thing and have raised it in a new thread.
https://www.drupal.org/node/2681079