I've built a Fieldtype Addon and have a request to make it SafeCracker compatible.

The docs are not very clear on how to achieve this.


I am including my own JS files for EE's CP and this works, if I add the JS file to the theme's folder will SafeCracker just work?

2 Answers 2


So long as you are using those approved methods for adding JS and CSS for your fieldtype, and your end-users aren't using safecracker_head="no", yes, it will indeed work.

  • What's the appoved methods? I'm using: $this->EE->cp->load_package_js('cp'); $this->EE->javascript->output('js_function'); Commented Nov 27, 2012 at 21:17
  • The methods listed in the user guide link. Commented Nov 27, 2012 at 21:37

Just try adding your fieldtype to a Safecracker field and see whether you have any problems. Look for php errors, and javascript console errors.

Generally, the main issues you will run into will either be loading static css/js files which aren't accessible outside the control panel, or calling php functions which aren't accessible outside the control panel.

For example, a fieldtype I added Safecracker support to was making an AJAX call to a method on my mcp file. I had to change this to a regular EE action so that it could be called from outside the control panel.

One final thing to watch for is making sure your fieldtype looks alright with a white/different color background.

  • Yeah the accesible files is my issue. How does EE know how to load the correct files in the right situation? In the CP this works fine. But the paths will be different through SafeCracker. Commented Nov 27, 2012 at 21:20
  • Have you actually tried cp->load_package_js in Safecracker? I don't know off hand whether it works in Safecracker, but I think it does. Commented Nov 27, 2012 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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