Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Date Picker

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-26-2018, 07:44 AM
 
Soptareanu Alex Soptareanu Alex is offline
 

Member
  
Join Date: Sep 2016
Posts: 24
 

Default Date Picker

I need to insert a new element in Order Info page as a datetime picker. How can i achive this task. Is anyone that can help me ?

This is my decoration of Info class :

class Info extends \XLite\View\Order\Details\Admin\Info implements \XLite\Base\IDecorator
{
/**
* Get order delivery date
*
* @return string
*/
protected function getDeliveryDate()
{
$_POST['order'] = $this->getOrder();
if($this->getOrder() != null){
if($this->getOrder()->delivery_date != null || $this->getOrder()->delivery_date != FALSE){
$delivery_date = date('d-m-Y', $this->getOrder()->delivery_date);
}else{
$delivery_date = null;
}
}else{
$delivery_date = null;
}

return $delivery_date;
}
}
Attached Thumbnails
Click image for larger version

Name:	dateTimePicker.PNG
Views:	434
Size:	25.9 KB
ID:	5108  
__________________
alex
Reply With Quote
  #2  
Old 02-26-2018, 11:31 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Date Picker

The standard date picker widget is this one: \XLite\View\DatePicker (decorates the \XLite\View\FormField\Input\Text field widget).

It was designed to work inside model form widgets, but you can insert it into any template as follows:
HTML Code:
{% form 'XLite\\Module\\YOUR_DEV_ID\\YOUR_MODULE_ID\\View\\Form\\SomeFormName' %} <div class="table-label date-label table-label-required"> <label for="date">{{ t('Some label') }}</label> </div> {{ widget('XLite\\View\\DatePicker', required='true', fieldName='date', value=this. getDeliveryDate()) }} <div class="table-button">{{ widget('XLite\\View\\Button\\Submit', style='regular-main-button', label=t('Update the delivery date')) }}</div> {% endform %}

The custom form class can be as simple as this:
PHP Code:
<?php
namespace XLite\Module\YOUR_DEV_ID\YOUR_MODULE_ID\View\Form;

class 
SomeFormName extends \XLite\View\Form\AForm
{
    protected function 
getDefaultTarget()
    {
        
// Put the target that matches your custom controller class
        
return 'my_custom_controller';
    }

    protected function 
getDefaultAction()
    {
        
// Put the name of the action that handles changing of the delivery date
        
return 'update_delivery_date';
    }
}
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions

Last edited by qualiteam : 02-26-2018 at 11:33 PM.
Reply With Quote

The following user thanks qualiteam for this useful post:
Soptareanu Alex (02-27-2018)
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:29 AM.

   

 
X-Cart forums © 2001-2020