1

Suppose i am building a custom form element with

hook_element_info()

Is there a way , in another module,to check this element's existence before inserting it to a form?

2

You can invoke the hook yourself to check for the existence of a specific element type:

if (in_array('some_element_key', array_keys(module_invoke_all('element_info')))) {
  // The element type exists.
}
|improve this answer|||||
  • Thanks, im pretty sure this will work, but as i tried with system_element_info(), i see that it runs before my hook_element_info() and does not contain my custom element, any logic to that? – Pan Chrono Nov 11 '13 at 14:51
  • Sorry I don't understand. The above code will give you all of the element types defined in the system, including any defined in custom modules – Clive Nov 11 '13 at 14:52
  • So the system_element_info() will give me only the system-provided ones? thats all.. – Pan Chrono Nov 11 '13 at 14:54
  • 1
    Good to clear that out, cheers – Pan Chrono Nov 11 '13 at 15:01
  • 1
    @PanChrono system is a module, just one provided by core that you can't disable. There really isn't anything terribly special about it. – mpdonadio Nov 11 '13 at 15:02

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.