carbon-fields icon indicating copy to clipboard operation
carbon-fields copied to clipboard

Fields with time not saved (Gutenberg Block)

Open enky00 opened this issue 5 years ago • 2 comments

Version

  • Carbon Fields: Version 3.0.2
  • WordPress: 5.1
  • PHP: 7.1.6

Expected Behavior

Choose a Time or Date/Time and it will be saved and the front end output is right

Actual Behavior

I choose a time or Time/Date, click save, reload the page in backend and the input fields are empty. The output in frontend is Invalid date. This only happens with "time" and "date_time"

Container definition

add_action( 'carbon_fields_register_fields', 'crb_select' );
function crb_select() {
	Block::make('crb-select-fields')
    ->add_fields( array(
			Field::make( 'select', 'crb_select', __( 'Choose Options' ) )->set_options( 'getValuesFromOptionsPage' ),
			Field::make( 'text', 'crb_select_content', 'Content2' )->set_default_value( getUniqueID() )->set_attribute( 'readOnly' , true),
			Field::make( 'time', 'crb_select_time', 'Event Start' ),
			Field::make( 'date', 'crb_event_start_date', __( 'Event Start Date' ) ),
			Field::make( 'date_time', 'crb_select_time_and_date', 'Event date and Time' ),
    ) )
    ->set_render_callback( function ( $block ) {
			//print_r($block);
        ?>
				<div class="container">
					<div class="row">
						<div class="col-12 col-sm-12">
							<hr>
						</div>
					</div>
					<div class="row">
						<div class="col-12 col-sm-12">
						<?php echo $block['crb_select_time']; ?>
						<br>
						<?php echo $block['crb_event_start_date']; ?>
						<br>
						<?php echo $block['crb_select_time_and_date']; ?>
						</div>
					</div>
					<div class="row">
						<div class="col-12 col-sm-12">
							<hr>
						</div>
					</div>
				</div>
        <?php
    } );
};

Steps to Reproduce the Problem

  1. Register the Gutenberg Block (Code above)
  2. Use the time, date and date_time fields
  3. Save
  4. Reload the Edit Page, time and date_time will be empty
  5. Open the Page in Frontend, you will see invalid date twice.

Comments

Please add any other comments here

enky00 avatar Mar 08 '19 12:03 enky00

I have the same problem

prochorz avatar Mar 25 '21 21:03 prochorz

Is there a solution / workaround for this by now? I have the same with the date field.

StudioRATATA avatar May 04 '23 09:05 StudioRATATA