1

So I'm working on a module that requires it's own tab in the EE Control Panel edit/publish pages. One of the fields in the module's tab is a date picker.

I've got the module saving the date to my module's DB as well as repopulating the date when editing an entry. However I'm not sure what to do with the "Localized/Fixed" dropdown that appears after the date picker.

How do I save and repopulate whether the user has selected "Localized" or "Fixed"?

Thanks in advance!

0

The built-in Localize class documentation will help you here. It is used like this:

ee()->localize->now

Take a look at your EE source code in many of the core files - one example is the libraries/Template.php file - you will see lots of usage of the line of code above. EE handles this internally so you most likely don't need to worry about it.

EDIT 1: Look at the EE source code for the date fieldtype

If you look at the following file fieldtypes/date/ft.date.php that will show you how to use the Localize class. You need to modify the $data array that is saved. Look at the following methods:

  • save
  • grid_save: Look for the $this->settings['localize'] !== TRUE
  • display_field: That shows you how to pull the localized string (if set)
  • grid_display_settings: Look for the $data['localize'] var

This is a concrete example of exactly what you are trying to do (based on your question). You might want to just subclass the Date fieldtype and add your own customizations where needed - that way your plugin will stay in-line with the Ellis Lab development of the Date field (i.e. future proof it to some degree). Good luck.

| improve this answer | |
  • Thanks for the direction @tatlar. However, I think the Localize class is only a portion of the answer. When saving a date from a module's tab, I'm not sure how I'm supposed to save/repopulate the Localized/Fixed select that shows up alongside the Date field. – Jesse Schutt May 4 '15 at 22:01
  • See EDIT 1 above. – tatlar May 4 '15 at 22:50

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.