Jump to content

frontend datepicker (uikit)

Recommended Posts

I have been searching whole day and had all topics on this forum. I can't get a datepicker working on the frontend. The frontend is build with uikit (same as admin).

I have this code at the moment. The field gets filled but no datepicker. I also have this in <head>

 <script src="/wire/modules/Jquery/JqueryCore/JqueryCore.js"></script>
    <script src="/wire/modules/Jquery/JqueryUI/JqueryUI.js"></script>
    <script type='text/javascript' src='/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.min.js?v=106-1529786878'></script>
    <script src="/wire/modules/Inputfield/InputfieldDatetime/timepicker/jquery-ui-timepicker-addon.min.js"></script>
    <link rel="stylesheet" href="/wire/modules/Inputfield/InputfieldDatetime/timepicker/jquery-ui-timepicker-addon.min.css"/>



$out = '';

// create a new form field (also field wrapper)
$form = $modules->get("InputfieldForm");
$form->action = "./";
$form->method = "post";
$form->attr("id+name", 'subscribe-form');
$form->attr("class", "InputfieldContent uk-form-controls");

//$f = $modules->InputfieldDatetime;
$f = $modules->get('InputfieldDatetime');
$f->label = "Date";
$f->attr("name+id", "date");
$f->attr("class", "FieldtypeDatetime uk-input hasDatepicker initDatepicker InputfieldDatetimeDatepicker ");
$f->datepicker = 3;
$f->dateInputFormat = "Y-m-d";
$f->timeInputFormat = "H:i:s";
$f->attr("value", time());;

// oh a submit button!
$submit = $modules->get("InputfieldSubmit");
$submit->attr("value", "Add");
$submit->attr("id+name", "submit_mating");

// form was submitted so we process the form
if ($input->post->submit_mating) {

    // user submitted the form, process it and check for errors

    if ($form->getErrors()) {
        // the form is processed and populated
        // but contains errors
        $out .= $form->render();
    } else {


        $date = $form->get("date")->value;
        $date = $sanitizer->date($date);
        $title = date("Y-m-d-g-i", $date);

        $p = new Page();
        $p->template = 'feeding'; // example template
        $p->parent = 1089; //$user->id; // example parent
        $p->name = $user->name . "-mating-" . $date; // example name
        $p->title = $title;


        $p->title->setLanguageValue('default', $title); //default
        $p->title->setLanguageValue('de', $title); //german
        $p->title->setLanguageValue('nl', $title); //dutch

        //echo var_dump($p);


} else {
    // render out form without processing
    $out .= $form->render();


echo $out;

What am I missing?

Share this post

Link to post
Share on other sites

got it figured out.  A faulty reference to uikit v2 was messings things up.

  • 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...