1

I have created a custom field type which integrates with a web service. I need to create a simple interface which allows the User ID and API key to be configured globally.

Will I need to create a module for this?

A simple example would be greatly appreciated!!

2

You can create a configuration page for your fieldtype by including a display_global_settings() and a save_global_settings() which display and save the settings respectively.

When your fieldtype class is instantiated your current settings are passed to a public settings property. You access your current settings within the display_global_settings() method with $this->settings['setting_name']. To display the settings page, return a string containing the HTML. You do not need to include a form tag or submit button in the returned HTML, these will be added for you.

To save the settings, you will create a save_global_settings() method. This method should retrieve the values using the $this->EE->input->post() method. You can manipulate the settings however you need, or simply place them all into a single array. The value you return from this method will be saved to the database and set to $this->settings next time the class is instantiated.

You can set the default settings value by returning it from the install() method.

You can find some examples under the global setting section of the fieldtype developer docs.

1
  • Fantastic, this worked perfectly :)
    – Lea Hayes
    Apr 3 '13 at 21:38

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.