• Resolved arthurlutte

    (@arthurlutte)


    Hi,

    I tried to create a simple date input for a taxonomy. When I select a date before 1900, it is not registered. The datepicker seems to work corectly and the date format is the default one (m/d/Y). When I try to save a tax, the input value is not saved…

    Inunderstandable for me. Can you help ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    1. Can you provide the code you’re trying with/
    2. If you’re using any of the taxonmy_* field types, those don’t save to post meta, they save as terms in the taxonomy. So I’d check your terms list for the taxonomy to see if the values you’re expecting are there.

    Thread Starter arthurlutte

    (@arthurlutte)

    This is my code. The date input works and does register the dates, except when I try to add a date before 1905. When I save the taxonomy with this date 08/13/1899, I have an empty date field and my term meta is empty too. (but it work for 08/13/1980). The date picker does work and the date format is the good one…

    add_action( 'cmb2_admin_init', 'details_taxonomy_metabox' );
    function details_taxonomy_metabox() {
    	$cmb_term = new_cmb2_box( array(
    		'id'               => 'taxonomy_details',
    		'title'            => esc_html__( 'Taxomomy Details ', 'cmb2' ),
    	'object_types'     => array( 'term' ), 
            'taxonomies'       => array( 'authors' ), 
    ) );
    	$cmb_term->add_field( array(
    		'name' => 'Date de naissance',
    		'id'   => 'birth-date',
    		'type' => 'text_date',
    	) );	
    }
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not managing to re-create at the moment.

    https://cloudup.com/cKSo3iZ1Dkp

    Using the code below at least. I had to amend it to get a date range that went that far back. Defaults didn’t cover that many.

    add_action( 'cmb2_admin_init', 'details_taxonomy_metabox' );
    function details_taxonomy_metabox() {
    	$cmb_term = new_cmb2_box( array(
    		'id'           => 'taxonomy_details',
    		'title'        => esc_html__( 'Taxomomy Details ', 'cmb2' ),
    		'object_types' => array( 'term' ),
    		'taxonomies'   => array( 'category' ),
    	) );
    	$cmb_term->add_field( array(
    		'name' => 'Date de naissance',
    		'id'   => 'birth-date',
    		'type' => 'text_date',
    		'attributes' => array(
    			// CMB2 checks for datepicker override data here:
    			'data-datepicker' => json_encode( array(
    				'yearRange'       => '-150:+0',
    			) ),
    		),
    	) );
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘text_date can’t save date before 1905’ is closed to new replies.