Skip to content

Commit

Permalink
Add today default for date widget (#336).
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Aug 16, 2024
1 parent 9f21fe8 commit dfc21b4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions defaults/core/cms/fields/date.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<script>
import { isDate, makeDate, formatDate } from '../date_checker.js';
export let field;
export let schema, parentKeys, field;
let today;
if (schema && schema[parentKeys]?.options) {
today = schema[parentKeys].options.includes("today");
}
if (today) {
let date = new Date();
date = makeDate(date);
field = formatDate(date, field);
}
const bindDate = date => {
field = formatDate(date, field);
Expand All @@ -13,4 +24,4 @@
value={isDate(field) ? makeDate(field) : null}
on:input={date => bindDate(date.target.value)}
required
/>
/>

0 comments on commit dfc21b4

Please sign in to comment.