# Using Calendar Date Selection in a Block

**URL:** <https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919>\
**Category:** Developing with Concrete\
**Created:** [July 20, 2023, 4:44pm UTC](https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919 "2023-07-20T16:44:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chrouglas](https://forums.concretecms.org/user_avatar/forums.concretecms.org/chrouglas/32/4951_2.png) [@Chrouglas](https://forums.concretecms.org/u/Chrouglas)\
**Post date:** [July 20, 2023, 4:44pm UTC](https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919/1 "2023-07-20T16:44:43Z")

</div>

Anyone have any quick thoughts on how I might use the Date picker widget from the Calendar Event Add form in a custom block?

It looks like I need to use concreteDurationSelector but I can’t figure out how to get that working.

Also, Can anyone else verify that the Calendar Event Add Form only gives options for AM times?

Thanks in advance  
C

---

<div class="post-metadata">

**Author:** ![mnakalay](https://forums.concretecms.org/user_avatar/forums.concretecms.org/mnakalay/32/6276_2.png) [@mnakalay](https://forums.concretecms.org/u/mnakalay)\
**Post date:** [July 25, 2023, 10:52am UTC](https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919/2 "2023-07-25T10:52:00Z")

</div>

Would this help:

> **[How to use the date time widget in concrete5 5.7](https://documentation.concretecms.org/tutorials/how-to-use-the-date-time-widget-in-concrete5-5-7-blocks)**
>
> Use the date time widget to create a date only picker or a date and time picker.

---

<div class="post-metadata">

**Author:** ![JohntheFish](https://forums.concretecms.org/user_avatar/forums.concretecms.org/johnthefish/32/3767_2.png) [@JohntheFish](https://forums.concretecms.org/u/JohntheFish)\
**Post date:** [July 25, 2023, 11:09am UTC](https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919/3 "2023-07-25T11:09:48Z")

</div>

Do you need it to connect to the calendar, or do you just need a date/time picker? If the latter, you can use the HTML date/time element through the form helper.

---

<div class="post-metadata">

**Author:** ![Chrouglas](https://forums.concretecms.org/user_avatar/forums.concretecms.org/chrouglas/32/4951_2.png) [@Chrouglas](https://forums.concretecms.org/u/Chrouglas)\
**Post date:** [July 25, 2023, 1:37pm UTC](https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919/4 "2023-07-25T13:37:58Z")

</div>

Thanks for the replies. I don’t need the calendar for what I am doing. I was hoping to tap into the functionality of the event dates where the beginning date selection would change the end date but I think I can figure that out separately.

I ran into an issue though with the Date Widget was not functioning properly when not logged in as admin. I tried on a fresh install of 9.2.0 and nothing. Turns out the JqueryUI was not loading even after including

```auto
$this->requireAsset('jquery/ui');

```

in the controller’s view() function.

Yesterday I found this though and it is working now.

> [@V9: which asset provides date picker?](https://forums.concretecms.org/t/v9-which-asset-provides-date-picker/1568/5):
>
> Ran into this issue today also. The built in form block still tries to use the jQuery UI datepicker if you have a date/time field, which is broken unless your theme pulls in all of core/cms or you manually add jQuery UI to your theme. My fix in page\_theme.php registerAssets(): $al = \Concrete\Core\Asset\AssetList::getInstance(); $al-\>register('css', 'jquery/ui', 'css/jquery-ui.css'); $al-\>register('javascript', 'jquery/ui', 'https://code.jquery.com/ui/1.13.2/jquery-ui.min.js', ['local' =\> false…

Thank you [chemmett](https://forums.concretecms.org/u/chemmett)

For fellow Googlers…  
in a block’s view.php file

```auto
<?php
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$dtfh = $app->make('helper/form/date_time'); 
?>

<label for="start"><?=t('Start Date')?></label>
<?=$dtfh->date('start', $start)?>

<label for="end"><?=t('End Date')?></label>
<?=$dtfh->date('end', $end)?>

```

And in the block’s controller.php file’s view function

```auto
public function view()
{
   $al = \Concrete\Core\Asset\AssetList::getInstance();
   $al->register('css', 'jquery/ui', 'css/jquery-ui.css');
   $al->register('javascript', 'jquery/ui', 'https://code.jquery.com/ui/1.13.2/jquery-ui.min.js', ['local' => false]);
   $al->registerGroup('jquery/ui', [
      ['javascript', 'jquery/ui'],
      ['css', 'jquery/ui']
   ]);
   $this->requireAsset('jquery/ui');
}

```

Hopefully this will help for others who run into the same situation.

Separately but much less important: the DatePicker runs a script that takes the selected date, formats it properly, and adds it to a hidden text input field. Is there a better way (and I am sure there is) to tap into that value besides doing a setTimeout to wait for the DatePickers script to finish? This is truly not C5 related so feel free to give this the silent treatment.

Thanks again for all your input.  
C

---

<div class="post-metadata">

**Author:** ![Chrouglas](https://forums.concretecms.org/user_avatar/forums.concretecms.org/chrouglas/32/4951_2.png) [@Chrouglas](https://forums.concretecms.org/u/Chrouglas)\
**Post date:** [July 25, 2023, 3:36pm UTC](https://forums.concretecms.org/t/using-calendar-date-selection-in-a-block/5919/5 "2023-07-25T15:36:43Z")

</div>

And of course it can’t be that simple…  
When the page is in edit mode there is some weird conflict.  
Added

```auto
if (!$c->isEditMode()) {

}

```

around the asset registration.
