How to add datepicker in magento 2 frontend formDisable future dates in magento datepickerMagento 2 : frontend calendar localizationAdd datepicker on frontend?How to save date in database from frontend?magento 2: How add time to datepicker in backendMagento 2 Add Datetime picker in system.xmlMagento 2 : Add Date Picker in 24 Hour Format in Admin FormDatepicker Options in Knockout JS Binding is not workingMagento 2 - Admin form datepicker not working in custom tabHow to show time chooser in datepicker on magento configurationDatepicker issue in Magento 1Magento 2 UI Form datepicker, default date and strange behaviour
How do ballistic trajectories work in a ring world?
My professor has told me he will be the corresponding author. Will it hurt my future career?
What is the shape of the upper boundary of water hitting a screen?
Will Jimmy fall off his platform?
What are some bad ways to subvert tropes?
How do I explain that I don't want to maintain old projects?
How was the website able to tell my credit card was wrong before it processed it?
How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant
Those who speak do not know, those who know do not speak
What is the highest level of accuracy in motion control a Victorian society could achieve?
How to reclaim personal item I've lent to the office without burning bridges?
In layman's terms, does the Luckstone just give a passive +1 to all d20 rolls and saves except for death saves?
What purpose does mercury dichloride have in fireworks?
What was the nature of the known bugs in the Space Shuttle software?
When is one 'Ready' to make Original Contributions to Mathematics?
Can one block with a protection from color creature?
What does the multimeter dial do internally?
Shipped package arrived - didn't order, possible scam?
What do you call a situation where you have choices but no good choice?
How did the IEC decide to create kibibytes?
What does "spinning upon the shoals" mean?
How to say "is going" in Russian in "this game is going to perish"
force:lightningQuickAction . Will implementing this open the component as modalpop up directly?
Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?
How to add datepicker in magento 2 frontend form
Disable future dates in magento datepickerMagento 2 : frontend calendar localizationAdd datepicker on frontend?How to save date in database from frontend?magento 2: How add time to datepicker in backendMagento 2 Add Datetime picker in system.xmlMagento 2 : Add Date Picker in 24 Hour Format in Admin FormDatepicker Options in Knockout JS Binding is not workingMagento 2 - Admin form datepicker not working in custom tabHow to show time chooser in datepicker on magento configurationDatepicker issue in Magento 1Magento 2 UI Form datepicker, default date and strange behaviour
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?
magento2 datepicker
add a comment |
I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?
magento2 datepicker
add a comment |
I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?
magento2 datepicker
I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?
magento2 datepicker
magento2 datepicker
asked Nov 18 '16 at 12:44
rajat kararajat kara
6715 silver badges24 bronze badges
6715 silver badges24 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
you can use the magento 2 datepicker.
It use the jquery_ui datepicker.
Try this in your phtml:
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
Example with form:
<div class="field col-sm-6 ">
<div class="response-field-date">
<div class="subtemplate-wrapper">
<label for="" style="" class="">Terminwunsch</label>
<div class="row">
<div class="input-box col-sm-12">
<input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
</div>
</div>
</div>
</div>
</div>
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
1
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
|
show 1 more comment
In my Magento 2 template file, I added following code to display a date picker field :
<?php
echo $block->getLayout()
->createBlock('MagentoCustomerBlockWidgetDob')
->toHtml()
?>
add a comment |
Yet another approach:
<div class="field date">
<label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
<div class="control">
<?=
$block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
->setData([
'name' => 'date',
'id' => 'date',
'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
'date_format' => 'dd-MM-y',
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => 1
])
->toHtml()
?>
</div>
</div>
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146448%2fhow-to-add-datepicker-in-magento-2-frontend-form%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can use the magento 2 datepicker.
It use the jquery_ui datepicker.
Try this in your phtml:
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
Example with form:
<div class="field col-sm-6 ">
<div class="response-field-date">
<div class="subtemplate-wrapper">
<label for="" style="" class="">Terminwunsch</label>
<div class="row">
<div class="input-box col-sm-12">
<input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
</div>
</div>
</div>
</div>
</div>
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
1
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
|
show 1 more comment
you can use the magento 2 datepicker.
It use the jquery_ui datepicker.
Try this in your phtml:
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
Example with form:
<div class="field col-sm-6 ">
<div class="response-field-date">
<div class="subtemplate-wrapper">
<label for="" style="" class="">Terminwunsch</label>
<div class="row">
<div class="input-box col-sm-12">
<input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
</div>
</div>
</div>
</div>
</div>
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
1
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
|
show 1 more comment
you can use the magento 2 datepicker.
It use the jquery_ui datepicker.
Try this in your phtml:
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
Example with form:
<div class="field col-sm-6 ">
<div class="response-field-date">
<div class="subtemplate-wrapper">
<label for="" style="" class="">Terminwunsch</label>
<div class="row">
<div class="input-box col-sm-12">
<input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
</div>
</div>
</div>
</div>
</div>
you can use the magento 2 datepicker.
It use the jquery_ui datepicker.
Try this in your phtml:
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
Example with form:
<div class="field col-sm-6 ">
<div class="response-field-date">
<div class="subtemplate-wrapper">
<label for="" style="" class="">Terminwunsch</label>
<div class="row">
<div class="input-box col-sm-12">
<input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
<script type="text/javascript">
require([
"jquery",
"mage/calendar"
], function($)
$('#datepicker').datepicker(
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
showMonthAfterYear: false,
dateFormat:'d.m.yy'
);
);
</script>
</div>
</div>
</div>
</div>
</div>
answered Nov 18 '16 at 12:58
IrvIrv
3761 silver badge7 bronze badges
3761 silver badge7 bronze badges
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
1
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
|
show 1 more comment
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
1
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
already added the above script but not working .
– rajat kara
Nov 18 '16 at 13:26
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
Did you activate the datepicker in the backend?
– Irv
Nov 18 '16 at 13:29
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
How to activate the datepicker in backend ?
– rajat kara
Nov 21 '16 at 6:56
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.
– Irv
Nov 23 '16 at 13:37
1
1
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
It works for me!
– Charvi Parikh
Jun 6 '18 at 12:41
|
show 1 more comment
In my Magento 2 template file, I added following code to display a date picker field :
<?php
echo $block->getLayout()
->createBlock('MagentoCustomerBlockWidgetDob')
->toHtml()
?>
add a comment |
In my Magento 2 template file, I added following code to display a date picker field :
<?php
echo $block->getLayout()
->createBlock('MagentoCustomerBlockWidgetDob')
->toHtml()
?>
add a comment |
In my Magento 2 template file, I added following code to display a date picker field :
<?php
echo $block->getLayout()
->createBlock('MagentoCustomerBlockWidgetDob')
->toHtml()
?>
In my Magento 2 template file, I added following code to display a date picker field :
<?php
echo $block->getLayout()
->createBlock('MagentoCustomerBlockWidgetDob')
->toHtml()
?>
answered Mar 2 '17 at 10:06
DependencyHellDependencyHell
8665 silver badges22 bronze badges
8665 silver badges22 bronze badges
add a comment |
add a comment |
Yet another approach:
<div class="field date">
<label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
<div class="control">
<?=
$block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
->setData([
'name' => 'date',
'id' => 'date',
'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
'date_format' => 'dd-MM-y',
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => 1
])
->toHtml()
?>
</div>
</div>
add a comment |
Yet another approach:
<div class="field date">
<label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
<div class="control">
<?=
$block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
->setData([
'name' => 'date',
'id' => 'date',
'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
'date_format' => 'dd-MM-y',
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => 1
])
->toHtml()
?>
</div>
</div>
add a comment |
Yet another approach:
<div class="field date">
<label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
<div class="control">
<?=
$block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
->setData([
'name' => 'date',
'id' => 'date',
'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
'date_format' => 'dd-MM-y',
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => 1
])
->toHtml()
?>
</div>
</div>
Yet another approach:
<div class="field date">
<label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
<div class="control">
<?=
$block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
->setData([
'name' => 'date',
'id' => 'date',
'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
'date_format' => 'dd-MM-y',
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => 1
])
->toHtml()
?>
</div>
</div>
answered Jun 28 at 8:05
DmitryDmitry
911 silver badge5 bronze badges
911 silver badge5 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146448%2fhow-to-add-datepicker-in-magento-2-frontend-form%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown