Support

Home Forums Event Espresso Premium Event Registration Questions Customisation

Event Registration Questions Customisation

Posted: July 17, 2013 at 7:58 am

Viewing 4 reply threads


Helen Armour

July 17, 2013 at 7:58 am

Having looked through the forums, I can see that the addition of a date picker field is a popular requirement. My client also requires a date picker and I cannot tell them that this functionality will be added at ‘some time’ in the future.

Is it possible to know when this functionality will be added to Event Espresso? I see in the core files that the date picker is included but commented out array('id'=>'DATE','text'=> __('Date Picker','event_espresso')) so would I be right to assume that this will be implemented soon?

I am happy to write my own javascript date picker but currently there is no way of specifying an id or class to any of the questions. Is there any way I could add these to individual questions?

I also saw that Josh suggested an alternative solution to a jquery date picker https://eventespresso.com/topic/date-of-birth-question/ but this would still require a level of customisation to remove the input labels and apply specific styles to those input fields.

Could you please advise if there is any customisation I could implement to address this issue at any level?

Thank you


Josh

  • Support Staff

July 17, 2013 at 11:14 am

Hi there,

It might be something that gets added to 3.x, or at least a few hooks to make it so a new question type can be added without hacking core. I mentioned this to one of the developers. The thing is right now were in the middle of a bug fix blitz so new features are on hold.

I think you can add a datepicker with jQuery though. The question inputs that get output all get unique class attributes and name attributes that can be used as selectors when you use jQuery.

If you add your own JS, you can use the $load_espresso_script global object to ensure that your custom scripts only run on Event Espresso’s pages. Some example code:

add_action('wp_enqueue_scripts', 'erqc_custom_scripts');

function erqc_custom_scripts() {
	global $load_espresso_scripts;

	if ( ! $load_espresso_scripts )
		return;
	// custom script located in /wp-content/uploads/espresso/
	wp_enqueue_script('my-custom-script', content_url('/uploads/espresso/mycustom.js'), array('jquery'), '1.0', true);
}

It might also be worthwhile to use the html5 datepicker and fall back to use jQueryUI when the browser doesn’t support the datepicker feature.

http://tjvantoll.com/2012/06/30/creating-a-native-html5-datepicker-with-a-fallback-to-jquery-ui/


Helen Armour

July 19, 2013 at 4:09 am

Thanks Josh,

I wasn’t keen to use the unique IDs as it doesn’t allow for the datepicker to be included dynamically as and when questions are added. I have however arrived at an alternative solution.

Since we can reasonably safely assume that when a date is required, the word ‘date’ will be included in the label; I simply used some JS to find ‘date’ in the content of the Labels. Here’s my code for anybody who wants to implement a datepicker in this way.

<code>	jQuery(&quot;label:contains(&#039;date&#039;), label:contains(&#039;Date&#039;)&quot;).next(&#039;input&#039;).datepicker({dateFormat: &quot;dd/mm/yy&quot;});
</code>

I just added the code to multi_registration_page_display.php and registration_page_display.php

.datepicker is a function from the JQuery-UI Library which just needs to be included in the head.


Helen Armour

July 19, 2013 at 4:11 am

<pre class=”brush: javascript; gutter: true; first-line: 1; highlight: []; html-script: false”>
jQuery("label:contains('date'), label:contains('Date')").next('input').datepicker({dateFormat: "dd/mm/yy"});


Dean

July 19, 2013 at 5:09 am

jQuery('label:contains("date"), label:contains("Date")').next('input').datepicker({dateFormat: "dd/mm/yy"});

Yeah the code formatter isn’t always easy to work with.

Viewing 4 reply threads

The support post ‘Event Registration Questions Customisation’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso