Jump to content

Custom Module Admin Form Time Input Element Supported


Recommended Posts

Anyone know if the <input type="time"> is supported when defining the admin form for a custom module?  It doesn't seem to render when I set it, even though documentation suggests it should be supported.

 

 

$this->fields_form[0]['form'] = array(
            'legend' => array(
                'title' => $this->l('Order Processing Cut-Off Time'),
            ),
            'input' => array(
                array(
                    'type' => 'time',
                    'label' => $this->l('Daily Order Cut-Off Time:'),
                    'desc' => $this->l('Set the time orders will be accepted for current day'),
                    'name' => 'prodman_pcutoff',
                    'required' => true
                )
            ),
            'submit' => array(
                'title' => $this->l('Save'),
                'class' => 'button'
            )
        );

 

 

 

Cheers

Link to comment
Share on other sites

Hi,

 

Yep, just been playing with that.  I can get a time only selector to render but documentation not clear on how I should override this correctly.

 

{extends file="helpers/form/form.tpl"}
 
{block name="script"}
    if ($(".timepicker").length > 0)
        $('.timepicker').timepicker({
        prevText: '',
        nextText: '',
        dateFormat: 'yy-mm-dd',
        // Define a custom regional settings in order to use PrestaShop translation tools
        currentText: '{l s='Now'}',
        closeText: '{l s='Done'}',
        ampm: false,
        amNames: ['AM', 'A'],
        pmNames: ['PM', 'P'],
        timeFormat: 'hh:mm:ss tt',
        timeSuffix: '',
        timeOnlyTitle: '{l s='Choose Time' js=1}',
        timeText: '{l s='Time' js=1}',
        hourText: '{l s='Hour' js=1}',
        minuteText: '{l s='Minute' js=1}',
    });
{/block}

 

 

Link to comment
Share on other sites

Hi

 

I found a solution

 

in fuction GetContent add

$this->context->controller->addJqueryUI('ui.datepicker');

in you form add

array(
	'type' => 'datetime',
	'label' => $this->l('Test time'),
	'name' => 'test_time',
	'desc' => $this->l('enter the time you want')
),

**test_time is a column with time format in table in you sql

in your objetmodel add (your_moduleClass.php)

/** @var string test_time*/
	public $test_time;

and in $definition array
'test_time'	=>	array('type' => self::TYPE_DATETIME, 'validate' => 'isPhpDateFormat'),

in the file module\your_module\views\templates\admin\_configure\helpers\form

extends file="helpers/form/form.tpl"}
{

{block name="input"}    
    {if $input.type == 'time'}
		<div class="row">
			<div class="input-group col-lg-4">
				<input
					id="{if isset($input.id)}{$input.id}{else}{$input.name}{/if}"
					type="text"
					data-hex="true"
					{if isset($input.class)}class="{$input.class}"
					{else}class="timepicker"{/if}
					name="{$input.name}"
					value="{$fields_value[$input.name]|escape:'html':'UTF-8'}" />
				<span class="input-group-addon">
					<i class="icon-calendar-empty"></i>
				</span>
			</div>
		</div>
	{else}
		{$smarty.block.parent}	
 	{/if}
{/block}
{block name="script"}

	if ($(".timepicker").length > 0)
		$(".timepicker").timepicker({
		pickDate: false
	});
	
	</script>
{/block}

tested on my 1.6 local server :)

 

@++

 

Loulou66

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
×
×
  • Create New...