1

I have an app that ask 2 things 1. How do you feel? 2. what date is it?

The answer to question 1 is shown correctly in the list but the date is always the value of the last entry.

To display the date, I have in the template:

@Content.Datum.ToString("dd-MM-yyyy")

(Datum is not misspelled, just Dutch)

  1. do I use the date the wrong way?
    1. if I should be using prefill that would be ok too but it is available for all registered users, so it would need to fit in the default code snippet as explained on https://github.com/2sic/2sxc/wiki/javascript-%242sxc.cms
  • Let's solve this :). Please post more code, that we can fix it. Pls also tell us, if you're trying to set the initial date so the user doesn't have to pick it (prefill), or what the date is for. – iJungleBoy Mar 14 '19 at 12:51
  • As Stackoverflow skips most of my code, I emailed the app to you. I hope the zip got through to your email, otherwise let me know. The date is just for the 'diary'. It doesn't need to be prefilled, just standard behaviour post-view. – Tycho de Waard Mar 15 '19 at 10:47

1 Answers1

0

Thanks Daniel, for helping out. There are 2 components to this issue. The answer to the question is: Use in the template >@entry.Datum.ToString("d") to apply the date, coming from the datePicker. The entry is a variable set in @foreach(var entry in AsDynamic(Data["Default"]))

The other part is to prefill the date with the current date. This can be accomplished by adding a bit of code to the script to allow users to put data in the site.

 <script>
   function addProject(tag) {
        $2sxc.cms.run(tag, "new", { contentType: "Diary", prefill: { Datum: new Date().toISOString() } })

    }
</script>