2

Let's say I have created a taxonomy vocabulary called ABC. For this vocabulary ABC, i want to create many fields using Drush.

I've tried

drush field-create ABC myfield,text,text_textfield

It works, doesn't give any error, but if I go to the admin panel, I click on structure => taxonomy then in the list I see ABC, I click on "Edit" then I click on the tab "Manage fields" where I expect to see my field. Because (correct me if I'm wrong) I think that the drush command line field-create ABC myfield should have added it. But no.

It's not there. But if I click on the combo of the "Add existing field" option, in the list, there's the myfield that I've just created!

It seems there "link" between ABC and myfield is not created. myfield is created, but it's not "included" in the ABC fields.

Am I doing something wrong, or missing something?

5

You are missing Entity type. See the documentation from drush

Create fields and instances. Returns urls for field editing.

Examples: drush field-create article Define new article fields via interactive prompts. open drush field-create article Define new article fields and then open field edit form for refinement. drush field-create article Create two new fields.
city,text,text_textfield
subtitle,text,text_textfield

Arguments: bundle Content type (for nodes). Name of bundle to attach fields to. Required.
field_spec Comma delimited triple in the form: field_name,field_type,widget_name. If widget_name is omitted, the default widget will be used. Separate multiple fields by space. If omitted, a wizard will prompt you.

Options: --entity_type Type of entity (e.g. node, user, comment). Defaults to node.

As you can see the entity type defaults to node . So you have to specify the entity type as taxonomy_term.

drush field-create ABC myfield,text,text_textfield --entity_type=taxonomy_term

  • Do you know how to get a list of all availaible entity_type? – Olivier Pons Dec 6 '12 at 13:47
  • entity_get_info($entity_type = NULL) can do it. – Dinesh Kumar Sarangapani Dec 6 '12 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.