This page contains notes derived from tech questions asked of APF’s developer.

Code from the Field Type Pack

They are in the directory admin-page-framework-field-type-pack/include/class/admin/demo.

About changing the size of the date field in a widget

You may use the ‘attributes’ argument to set inline CSS rules to the input tag.

About setting the month in the widget

Date setting is odd. For example, if you set new Date( 2015, 12, 25 ), the date picker will display January 26, 2016. The month is always off by one. Apparently the JavaScript standard for month notation is zero-based, so months are 0-11. I know. Dumb, right? In any case, to get it right, make sure the month number is one less than the actual month number. Here’s the JavaScript date object definition.

About setting date defaults

My problem statement was “I’d like the date field to appear with a pre-set date when the widget opens. I’ve tried using default and value, and I don’t seem to be able to make it do much of anything. In addition, I’d like the pop-up calendar to pop on that preset date, but it always opens on today’s date.”

To set a default value, you need to use the ‘default’ argument. To set a preset date marked in the pop-up date picker UI, you can use the `defaultDate` option of the datepicker jQuery plugin. The field type accepts the plugin options in the `options` argument. You would set it like this.

A JavaScript array is passed to the options argument, not PHP’s. Good JavaScript resource page on date-time pickers. The JavaScript date picker API.

About setting multiple option lines

About field_id naming in date fields

If the id field in ‘field_id’ has an underscore in it, the date picker doesn’t show up right. So use ‘targetdate’ and not ‘target_date’.

About using the EDD software licensing field type

According to the developer, “The ‘edd_software_licensing’ field type does not have a demo page. You use it like this:”

He says, “You would change the part YOUR_STORE_URI and YOUR_PRODUCT_NAME to yours. The field type pack itself uses that field type. You can check the actual usage in the file, admin-page-framework-field-type-pack/include/class/admin/setting/AdminPageFrameworkFieldTypePack_Setting_License.php.”