Jump to content
gunter

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
		$field->attr("id+name",$name."_start");
		$field->attr("value",$start);		
		$renderedFieldStart = $field->render();

		//setting second inputfield
		$field->attr("id+name",$name."_end");
		$field->attr("value",$end);
		$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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...