SOLVED: Form Element: Datepicker minTime/maxTime-Control "required" property is set incorrectly

A minor bug, but I just now encountered it.
The minTime and maxTime required properties are set incorrectly, thus always showing even if The Field-Type isn’t set to datepicker after the timesetting was toggled to true.

Form Element line 580 - 606

'time'                       => [
					'label'    => esc_html__( 'Enable time', 'bricks' ),
					'type'     => 'checkbox',
					'required' => [ 'type', '=', 'datepicker' ],
				],

				'l10n'                       => [
					'label'       => esc_html__( 'Language', 'bricks' ),
					'type'        => 'text',
					'inline'      => true,
					'description' => '<a href="https://github.com/flatpickr/flatpickr/tree/master/src/l10n" target="_blank">' . esc_html__( 'Language codes', 'bricks' ) . '</a> (de, es, fr, etc.)',
					'required'    => [ 'type', '=', [ 'datepicker' ] ],
				],

				'minTime'                    => [
					'label'       => esc_html__( 'Min. time', 'bricks' ),
					'type'        => 'text',
					'placeholder' => esc_html__( '09:00', 'bricks' ),
					'required'    => [ 'time', '!=', '' ],
				],

				'maxTime'                    => [
					'label'       => esc_html__( 'Max. time', 'bricks' ),
					'type'        => 'text',
					'placeholder' => esc_html__( '20:00', 'bricks' ),
					'required'    => [ 'time', '!=', '' ],
				],

If you once set your Field type to datepicker and check the timeoption the fields appear, and don’t disappear once the Field type has been set to anything else. This should be a minor fix by just setting the required property for minTime and maxTime to something like this (not tested, but just a guess):


				'minTime'                    => [
					'label'       => esc_html__( 'Min. time', 'bricks' ),
					'type'        => 'text',
					'placeholder' => esc_html__( '09:00', 'bricks' ),
					'required'    => [[ 'time', '!=', '' ],[ 'type', '=', 'datepicker' ]],
				],

And by the way - if you fix this, I know this is probably the wrong place and more like a feature request but it would be awesome if we could have a time-picker without date :wink:

Best regards
Suat

Hi Suat,
Thanks for the report. The min/max time controls should not remain visible after switching the Form field type away from Datepicker. We’ll update this thread once it’s fixed.

You’re right: The time-only picker would be a separate feature request :slight_smile:

We’ve addressed this in Bricks 2.3.10, now available as a one-click update in your WordPress Dashboard.

Please read the changelog entry before updating, and let us know if you experience any issues.