This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
lnapp/views/field/date.php

40 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<!-- field = field_name -->
<!-- text = field_text -->
<!-- value = value -->
<!-- enddate = js value -->
2016-08-30 15:59:46 +00:00
<?php $field = preg_replace('/[\[\]]/','_',Arr::get($data,'field')); ?>
<div class="form-group">
2016-08-30 15:59:46 +00:00
<label for="<?php echo $field; ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="input-group <?php echo Arr::get($data,'class','col-md-2'); ?>">
2016-08-30 15:59:46 +00:00
<input type="text" id="<?php echo $field; ?>_label" value="<?php echo Site::date(Arr::get($data,'value',time())); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
<input type="hidden" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>">
</div>
<?php
Script::factory()
->type('file')
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
Style::factory()
->type('file')
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
2016-08-30 15:59:46 +00:00
$("#'.$field.'_label").datepicker({
autoclose : true,
2016-08-30 15:59:46 +00:00
'.(Arr::get($data,'enddate') ? 'endDate : '.$data['enddate'].',' : '').'
todayHighlight: true,
format : "dd-M-yyyy",
todayBtn : true,
}).on("hide",function(ev) {
2016-08-30 15:59:46 +00:00
$("input[name=\"'.$data['field'].'\"]").val(ev.date.valueOf()/1000);
});
});');
?>