X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Date Picker (https://forum.x-cart.com/showthread.php?t=76030)

Soptareanu Alex 02-26-2018 07:44 AM

Date Picker
 
1 Attachment(s)
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;
}
}

qualiteam 02-26-2018 11:31 PM

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';
    }
}



All times are GMT -8. The time now is 04:47 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.