carbon-fields
carbon-fields copied to clipboard
Fields with time not saved (Gutenberg Block)
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
- Register the Gutenberg Block (Code above)
- Use the time, date and date_time fields
- Save
- Reload the Edit Page, time and date_time will be empty
- Open the Page in Frontend, you will see invalid date twice.
Comments
Please add any other comments here
I have the same problem
Is there a solution / workaround for this by now? I have the same with the date field.