Jump to content

datetime inputfield within custom inputfield - datepicker does not work

Recommended Posts

For a custom fieldtype/inputfield that contains two datetime variables (start + end) I want use two datetime inputfields in the render method.
Everything works, except the datepicker does not appear... does anybody know why?

	public function ___render() {

		$name = $this->attr('name');
		$value = $this->attr('value');
		//getting values for start and end
		$start 	= $value->data["start"]->toDateTimeString();;
		$end 	= $value->data["end"]->toDateTimeString();

		//preparing inputfield
		$field = $this->modules->get('InputfieldDatetime');
		$field->set("label", __("Date"));

		$field->attr("class", "uk-form-width-medium ");
		$field->required = true;
		$field->datepicker = InputfieldDatetime::datepickerClick;
		$field->dateInputFormat = 'Y-m-d';
		$field->timeInputFormat = 'H:i';
		$field->timeInputSelect = 1;

		//setting first inputfield
		$renderedFieldStart = $field->render();

		//setting second inputfield
		$renderedFieldEnd = $field->render();

		$out = $renderedFieldStart.$renderedFieldEnd;

		return $out; 


Share this post

Link to post
Share on other sites

Does it render with InputfieldDateTimeDatePicker class to initialize? Are the Inputfield scripts loaded?

Share this post

Link to post
Share on other sites

ok, thanks elabx for the hint to look at this..
I compared the html output against a working datetime inputfield...
the solution is, I have to set the class by hand... I tought it works automatically by setting $field>datepicker... but thats not true

		$field->attr("class", "FieldtypeDatetime InputfieldDatetimeDatepicker InputfieldDatetimeDatepicker1"); // I have to set the datepicker class by hand (1, 2 or 3)

		$field->datepicker = InputfieldDatetime::datepickerClick; // this is not needed, because it´s not working

so... I have a working date/time picker now, by setting the right class like this

  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...