3

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.

http://ellislab.com/expressionengine/user-guide/modules/safecracker/development.html#section_getting_it_to_work

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?

4

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.

| improve this answer | |
  • What's the appoved methods? I'm using: $this->EE->cp->load_package_js('cp'); $this->EE->javascript->output('js_function'); – Elliot Lewis Nov 27 '12 at 21:17
  • The methods listed in the user guide link. – Derek Hogue Nov 27 '12 at 21:37
0

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.

| improve this answer | |
  • 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. – Elliot Lewis Nov 27 '12 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. – Adrian Macneil Nov 27 '12 at 22:05

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.