Closed johnwalk61 closed 3 months ago
That is QuickAdd template syntax, it has nothing to do with values. Also, the format of a date input is dependent on your locale (language, country, etc). If you want the default todays date, that is very simple, you can do this:
const values1 = {
startdate: new Date(),
duedate: new Date(),
created: new Date(),
taskname: "Test task"
};
const modalForm = app.plugins.plugins.modalforms.api;
const result = await modalForm.openForm('New task form', { values: values1 });
return "#task " + result.getV('taskname')+" ➕ " + result.getV('created') +" 📅 " + result.getV('duedate')+" 🛫 " + result.getV('startdate');
Also, thanks of one of the latest features you can simplify the last like like this:
return "#task " + result.taskname + " ➕ " + result.created +" 📅 " + result.duedate +" 🛫 " + result.startdate;
Thanks Daniel for the great response. I tried this and the form comes up but the date fields are not populated with the default date. When the form is triggered, I get a warning: Invalid keys in form options... listing all the date fields
Any ideas?
Cheers
I figured it out:
```js quickadd
const defDate = moment().format('YYYY-MM-DD')
const values1 = {
taskname: "Test task",
created: defDate,
startdate: defDate,
duedate: defDate
};
const modalForm = app.plugins.plugins.modalforms.api;
const result = await modalForm.openForm('New task form', { values: values1 });
return "#task " + result.taskname + " ➕ " + result.created +" 📅 " + result.duedate +" 🛫 " + result.startdate;
Works great. Thanks for the help Daniel.
John
That is a bit unexpected, I will look into it, but I'm happy to see that you figured it out.
One last "touch" that you can di is, instead of doing all those +
on strings, you can use a single template string (this is plain javascript):
return `#task ${result.taskname} ➕ ${result.created} 📅 ${result.duedate} 🛫 ${result.startdate}`;
The outcome is the same, but it is a bit easier to read and reason about the format
For example, in QuickAdd's capture format i tried