Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    I’d suggest using a ‘text’ field and then including a datepicker script (think this one is included in WP core http://jqueryui.com/datepicker/) and apply it to the field by name/ID.

    In admin I do this for some of the fields using this code:

    jQuery(document).ready(function($) {
    	// Datepicker
    	$( "input#_job_expires" ).datepicker({
    		dateFormat: 'yy-mm-dd',
    		minDate: 0
    	});
    });

    So you’d need to do the same thing.

    Thread Starter rm65454

    (@rm65454)

    this is what I have so far.

    $fields[ 'job' ][ 'shift_date' ] = array(
    			'label'       => "Date Of Shift",
    			'type'        => 'text',
    			'placeholder' => 'yyyy-mm-dd',
    			'required'    => false,
    			'priority'    => 4.51
    		);

    I am at loss trying to figure out how to include the date picker. Have been looking at it for the last few days.

    Thread Starter rm65454

    (@rm65454)

    I have tried looking at the wp-job-manager-application-deadline plugin as well.

    Need the calender to look the same but even with that I was only able to add a field, the dropdown calender didnt show up.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    If you have the application deadline plugin to reference, look at the deadline.js file. You’ll need something similar to tell it to add a datepicker to your field.

    Thread Starter rm65454

    (@rm65454)

    I actually tried that. copied deadline.js as deadline2.js in the job manager’s asset folder and modified the code according but nothing. let me look for the code and paste it here.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    You should probably do it via your theme or a custom plugin. Did you remember to ‘enqueue’ your JS? http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Thread Starter rm65454

    (@rm65454)

    I thought the easiest way would be to just introduce a second field through the deadline plugin itself but that didnt work either

    $fields['job']['job_date'] = array(
    			'label'       => __( 'Shift date', 'job_manager_app_deadline' ),
    			'type'        => 'text',
    			'required'    => false,
    			'placeholder' => __( 'yyyy-mm-dd', 'job_manager_app_deadline' ),
    			'priority'    => "6.5"
    		);

    that introduced another field but still no drop down calender.

    I really cannot figure out how you are linking the calender to the front end.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    You cannot just add scripts and expect WP to load them, just like you cannot add new fields and expect the datepicker script to apply to them.

    For a quick solution (just to show you it working) edit your theme footer.php file and stick in:

    <script type="text/javascript">
       jQuery(document).ready(function($) {
    	// Datepicker
    	$( "input#_ shift_date" ).datepicker({
    		dateFormat: 'yy-mm-dd',
    		minDate: 0
    	});
       });
    </script>

    Assuming the input is called ‘shift_date’ that should then work.

    Best practice would be to enqueue a JS file with this code properly, but the above will work regardless.

    Thread Starter rm65454

    (@rm65454)

    Thanks for the dirty solution. I am trying to get it working by using the enqueue the js script file but no luck.

    here is the code for the js file

    jQuery( "#_shift_date" ).datepicker( {
    	minDate: 0,
    	"dateFormat": 'yy-mm-dd'
    } );

    here is what I did to the wp-job-manager-master file

    function form_fields( $fields ) {
    	wp_enqueue_script( 'wp-job-manager-shift', '/assets/js/shiftdate.js', array( 'jquery', 'jquery-ui-datepicker' ), '1.0', true );
    $fields[ 'job' ][ 'shift_date' ] = array(
    			'label'       => __('Date Of Shift','wp-job-manager-shift'),
    			'type'        => 'text',
    			'placeholder' => __('yyyy-mm-dd','wp-job-manager-shift'),
    			'required'    => false,
    			'priority'    => 4.51
    		);
    
    		return $fields;
    	}

    I think i am missing something. Will try to read up some more.

    Apologize for my non existent coding skills but I really appreciate you helping me fix this even though it feel outside the usual scope of support.

    Thank you so much.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    2 things.

    1. Put the JS file in your theme, not the plugin folder. Otherwise you’ll lose it in updates.
    2. Do the things separately. Enqueue your script from its own function. This example is pulled straight from the codex, I’ve just renamed some functions:

    function enqueue_custom_shift_js() {
    	wp_enqueue_script(
    		'wp-job-manager-shift',
    		get_stylesheet_directory_uri() . '/assets/js/shiftdate.js',
    		array( 'jquery' )
    	);
    }
    
    add_action( 'wp_enqueue_scripts', 'enqueue_custom_shift_js' );

    After doing that, view the source of your page, check the script is there, and check it ‘loads’ if you click on it (so you know the path is correct).

    Thread Starter rm65454

    (@rm65454)

    Thanks for helping me mikejolley.

    you can mark this as resolved.

    Thread Starter rm65454

    (@rm65454)

    actually one problem. if there is an error the page does not show it. it just looks like nothing happened. is there a way to fix that?

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    What kind of error are we talking about?

    Thread Starter rm65454

    (@rm65454)

    if i already have a package in my cart and try to add another one.

    when i click on add to cart, nothing happens but when i check in my cart, there is an error saying that the package is already in the cart.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    In your page’s content, add [shop_messages] shortcode above any thing else. This will output those notices.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘custom date field with drop down calender’ is closed to new replies.