makeElementId($data, $form);
if($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
$data['attributes']['tabindex'] = $tabIndex;
}
$elMarkup = "buildAttributes($data['attributes']) . ">";
$this->getDateFormatConfigJSON($data['settings'], $form, $data['attributes']['id']);
$html = $this->buildElementMarkup($elMarkup, $data, $form);
echo apply_filters('fluenform_rendering_field_html_' . $elementName, $html, $data, $form);
}
public function getAvailableDateFormats()
{
$dateFormats = apply_filters('fluentform/available_date_formats', array(
'm/d/Y' => 'm/d/Y - (Ex: 04/28/2018)', // USA
'd/m/Y' => 'd/m/Y - (Ex: 28/04/2018)', // Canada, UK
'd.m.Y' => 'd.m.Y - (Ex: 28.04.2019)', // Germany
'n/j/y' => 'n/j/y - (Ex: 4/28/18)',
'm/d/y' => 'm/d/y - (Ex: 04/28/18)',
'M/d/Y' => 'M/d/Y - (Ex: Apr/28/2018)',
'y/m/d' => 'y/m/d - (Ex: 18/04/28)',
'Y-m-d' => 'Y-m-d - (Ex: 2018-04-28)',
'd-M-y' => 'd-M-y - (Ex: 28-Apr-18)',
'm/d/Y h:i K' => 'm/d/Y h:i K - (Ex: 04/28/2018 08:55 PM)', // USA
'm/d/Y H:i' => 'm/d/Y H:i - (Ex: 04/28/2018 20:55)', // USA
'd/m/Y h:i K' => 'd/m/Y h:i K - (Ex: 28/04/2018 08:55 PM)', // Canada, UK
'd/m/Y H:i' => 'd/m/Y H:i - (Ex: 28/04/2018 20:55)', // Canada, UK
'd.m.Y h:i K' => 'd.m.Y h:i K - (Ex: 28.04.2019 08:55 PM)', // Germany
'd.m.Y H:i' => 'd.m.Y H:i - (Ex: 28.04.2019 20:55)', // Germany
'h:i K' => 'h:i K (Only Time Ex: 08:55 PM)',
'H:i' => 'H:i (Only Time Ex: 20:55)',
));
$formatted = [];
foreach ($dateFormats as $format => $label) {
$formatted[] = [
'label' => $label,
'value' => $format
];
}
return $formatted;
}
private function getDateFormatConfigJSON($settings, $form, $id)
{
$dateFormat = ArrayHelper::get($settings, 'date_format');
if (!$dateFormat) {
$dateFormat = 'm/d/Y';
}
$customConfigObject = trim(ArrayHelper::get($settings, 'date_config'));
if(!$customConfigObject || substr($customConfigObject, 0, 1) != '{' || substr($customConfigObject, -1) != '}') {
$customConfigObject = '{}';
}
$hasTime = $this->hasTime($dateFormat);
$time24 = false;
if($hasTime && strpos($dateFormat, 'H') !== false) {
$time24 = true;
}
$config = apply_filters('fluentform/frontend_date_format', array(
'dateFormat' => $dateFormat,
'enableTime' => $hasTime,
'noCalendar' => !$this->hasDate($dateFormat),
'disableMobile' => true,
'time_24hr' => $time24
), $settings, $form);
$config = json_encode($config, JSON_FORCE_OBJECT);
add_action('wp_footer', function () use ($config, $customConfigObject, $id, $form) {
?>