1

:)

I am trying to develop a new fieldtype and would like to display different markup depending on whether the field was requested by the user or in the backend.

Is there a reliable way to detect in the display_field() function whether it was requested via the {exp:safecracker} {custom_fields} loop.

1 Answer 1

3

You could check for the presence of the Safecracker library:

if (isset(ee()->safecracker))

Or check if you're in the control panel

if (REQ === 'CP')
2
  • 1
    That's what I do too. Use if(isset($this->EE->safecracker)) for versions prior to EE 2.6 though. ;) Commented Jul 31, 2013 at 18:14
  • Thanks very much gents. Just got around to it and it works brilliant. :) Commented Aug 27, 2013 at 17:16

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.