Skip to content

Commit 7298368

Browse files
authored
Merge pull request #130 from BoldGrid/enforce-date-format-1
Enforce Date Format
2 parents cfc57f2 + 5682b46 commit 7298368

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

includes/fields/class-field-date.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function render( $field_settings, $form_id ) {
2525
<?php $this->print_label( $field_settings ); ?>
2626

2727
<div class="wpuf-fields">
28-
<input id="wpuf-date-<?php echo esc_attr( $field_settings['name'] ); ?>" type="text" class="datepicker <?php echo ' wpuf_'.esc_attr( $field_settings['name'] ).'_'. esc_attr($form_id); ?>" data-required="<?php echo esc_attr($field_settings['required']) ?>" data-type="text" name="<?php echo esc_attr( $field_settings['name'] ); ?>" placeholder="<?php echo esc_attr( $field_settings['format'] ); ?>" value="<?php echo esc_attr( $value ) ?>" size="30" />
28+
<input id="wpuf-date-<?php echo esc_attr( $field_settings['name'] ); ?>" type="text" <?php echo esc_attr( $field_settings['enforce_format'] !== 'yes' ) ? '' : 'readonly'; ?> class="datepicker <?php echo ' wpuf_'.esc_attr( $field_settings['name'] ).'_'. esc_attr($form_id); ?>" data-required="<?php echo esc_attr($field_settings['required']) ?>" data-type="text" name="<?php echo esc_attr( $field_settings['name'] ); ?>" placeholder="<?php echo esc_attr( $field_settings['format'] ); ?>" value="<?php echo esc_attr( $value ) ?>" size="30" />
2929
<?php $this->help_text( $field_settings ); ?>
3030
</div>
3131
</li>
@@ -88,6 +88,18 @@ public function get_options_settings() {
8888
'priority' => 24,
8989
'help_text' => '',
9090
],
91+
[
92+
'name' => 'enforce_format',
93+
'title' => '',
94+
'type' => 'checkbox',
95+
'section' => 'advanced',
96+
'is_single_opt' => true,
97+
'options' => [
98+
'yes' => __( 'Enforce Date Format', 'weforms' ),
99+
],
100+
'priority' => 24,
101+
'help_text' => __( 'Disables Keyboard Input and uses the Datepicker Format', 'weforms' ),
102+
]
91103
];
92104

93105
return array_merge( $default_options, $settings );

0 commit comments

Comments
 (0)