3

Is there a property that is set by the field API once fields have been attached to an entity?

For example

$entity->fields_attached = TRUE

I have been unable to find any information on this, I am looking for a quick and easy way to know if fields have been attached to my own custom entities. If field API does not do something like I have suggested in the question I will handle it myself but I wanted to double check with you fine folks...

If not, I will make a suggestion for this for the Entity API in contrib whenever it attaches fields.

Many thanks in advance :)

  • Can't see anything like that going on. You could test a known field, if this is a specific question and you know to expect certain field, but obv. this no help if your question is more about the general case. – artfulrobot Apr 15 '12 at 19:45
  • Cheers for the answer :) You're right, I could certainly test for a specific field but I'm not sure I want to have to. I think a more generic solution would be easier. Am I suggesting something particularly crazy here? – user6803 Apr 16 '12 at 18:45
  • no, sounds sensible to me (have the issue all the time with $user which is field-less, where as $account = user_load($user->uid) is not) – artfulrobot Apr 17 '12 at 16:54
0

No, there is no property on the entity, but you can use field_info_instances() to check on which bundles the field is in use.

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.