I'm trying to pull up the 'settings' from some fieldtypes, particularly the safecracker_file or the file fieldtype.

I've instantiated the API and I'm calling :

$fieldsettings = $this->EE->api_channel_fields->get_settings(11);

where 11 is the reference of the Field ID. however, I'm constantly getting an empty array returned which would indicate that the field doesn’t exist.

I'm following the docs from here http://ellislab.com/expressionengine/user-guide/development/api/api_channel_fields.html#id10


This isn't clear from the docs, but you must call one these two methods prior to calling get_settings: setup_entry_settings or this method which is undocumented and takes no parameters:

  • $all_fields = ee()->api_channel_fields->fetch_custom_channel_fields(); $fields = $all_fields['custom_channel_fields'][ee()->config->item('site_id')]; – Joshua Baker Aug 29 '13 at 15:10

I would use Channel Data for this. The models in EE are so inconsistent, I find them hard to use reliably. Perhaps if the documentation was better they would be easy to use, but since it's not I created my own library.


Once you instantiate Channel Data, I would use this code.

$settings = $this->EE->channel_data->get_field($field_id)->row('field_settings');
$settings = is_string($settings) ? unserialize(base64_decode($settings)) : $settings;

In my experience, instantiating the FT object is really unnecessary when the data is stored in the db. However, you very well may need to do so. My answer is merely offering a possible alternative to solving your problem.

You could use a basic Active Record call, and do away with Channel Data. But I use Channel Data in all of my add-ons, so it's more like a global polymorphic model. I typically interface with Channel Data through my add-ons model class to keep a strict separation of MVC logic.

Again, not totally sure if this is what you are looking for, but I have solved this problem quite simply by fetching the settings from the DB myself. It should work just fine too provided the data you need isn't generated by instantiating the FT object.

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.