Skip to content

Datetime Widget Displays ‘{{now}}’ Instead of Current Date/Time When now Button is Not Clicked #7271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mirhamasala opened this issue Aug 27, 2024 · 2 comments · Fixed by #7272
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code

Comments

@mirhamasala
Copy link

mirhamasala commented Aug 27, 2024

Describe the bug
The bug occurs in the datetime widget. When a user does not explicitly click the now button to select the current date and time, the widget fails to automatically populate the field with the correct value. Instead, it inserts the placeholder text "{{now}}" as the literal value. This results in the datetime field displaying "{{now}}" rather than the actual date and time, which is likely unintended behavior.

To Reproduce

  1. Go to the Decap CMS editor and add a content entry that includes a datetime widget.
  2. In the datetime widget, ensure that the now button is available as an option.
  3. Without clicking the now button, leave the datetime field untouched (assuming it should default to the current date and time).
  4. Save the entry.
  5. View the saved content or inspect the field value in the backend.

Expected behavior
The datetime field should automatically populate with the current date and time.

Actual behavior
The field displays the literal text “{{now}}” instead of the actual date and time.

Screenshots
CleanShot 2024-08-27 at 16 06 26@2x

CleanShot 2024-08-27 at 16 04 25@2x CleanShot 2024-08-27 at 16 05 07@2x

Applicable Versions:

  • Decap CMS version: 3.3.2
  • Git provider: GitHub
  • OS: macOS Sonoma
  • Browser version: Chrome 127

CMS configuration

local_backend: true
site_url: https://fil.org
display_url: https://fil.org

backend:
  name: github
  branch: main
  repo: FilecoinFoundationWeb/filecoin-foundation
  base_url: https://decap-proxy.filecoin-foundation.workers.dev/

publish_mode: editorial_workflow
media_folder: "public/assets/images"
public_folder: "/assets/images"

slug:
  encoding: "ascii"
  clean_accents: true

created_on: &created_on
  name: "created-on"
  label: "Created On"
  widget: "datetime"
  default: "{{now}}"

updated_on: &updated_on
  name: "updated-on"
  label: "Updated On"
  widget: "datetime"
  default: "{{now}}"
  required: false

published_on: &published_on
  name: "published-on"
  label: "Published On"
  widget: "datetime"
  default: "{{now}}"
  required: false

header_config: &header_config
  name: "header"
  label: "Header"
  widget: "object"
  fields:
    - name: "title"
      label: "Title"
      widget: "string"
    - name: "description"
      label: "Description"
      widget: "text"

image_config: &image_config
  name: "image"
  label: "Image"
  widget: "object"
  required: false
  hint: Adding an image is optional. If no image is added, a default fallback image will be used automatically. Simply leave the image field empty to use the fallback.
  fields:
    - name: "src"
      label: "URL"
      widget: "image"
      allow_multiple: false
      choose_url: false
      required: false
      hint: "Use https://squoosh.app/ to compress images before uploading. Choose the WebP format and resize the image to 2000px width."
    - name: "alt"
      label: "Alt Text"
      widget: "hidden"
      required: false
      hint: "Refer to the W3C guidelines on when to use alt text: https://www.w3.org/WAI/tutorials/images/decision-tree/. Preferably, upload the image to ChatGPT 4.0 and use the prompt: 'Check the W3C guidelines (https://www.w3.org/WAI/tutorials/images/decision-tree/) and generate appropriate alt text for this image.'"

seo_metadata_description_max_characters: &seo_metadata_description_max_characters 220

meta_config: &meta_config
  name: "seo"
  label: "SEO Metadata"
  widget: "object"
  fields:
    - name: "title"
      label: "Meta Title"
      widget: "string"
    - name: "description"
      label: "Meta Description"
      widget: "text"
      pattern:
        - "^.{0,220}$"
        - "Must have at most 220 characters."
      hint: "To generate meta title and description, copy and paste the entry content into ChatGPT 4.0, then use the prompt: 'Generate a meta title and a meta description under 220 characters for the following content: [paste your content here].'"
    - name: "og"
      label: "Open Graph Metadata"
      widget: "object"
      collapsed: true
      fields:
        - name: "title"
          label: "Open Graph Title"
          widget: "string"
          required: false
        - name: "image"
          label: "Open Graph Image"
          widget: "image"
          allow_multiple: false
          choose_url: false
          required: false
    - name: "twitter"
      label: "Twitter Metadata"
      widget: "object"
      collapsed: true
      fields:
        - name: "title"
          label: "Twitter Title"
          widget: "string"
          default: "summary"
          required: false
        - name: "card"
          label: "Twitter Card"
          widget: "string"
          default: "summary"
          required: false
        - name: "site"
          label: "Twitter Site"
          widget: "string"
          required: false
        - name: "creator"
          label: "Twitter Creator"
          widget: "string"
          required: false

collections:
  - name: "pages"
    label: "Pages"
    files:
      - name: "about"
        label: "About"
        file: "src/content/pages/about.md"
        preview_path: "about"
        fields:
          - *header_config
          - *meta_config

      - name: "blog"
        label: "Blog"
        file: "src/content/pages/blog.md"
        preview_path: "blog"
        fields:
          - *header_config
          - name: "featured_entry"
            label: "Featured Post"
            widget: "relation"
            collection: "blog_posts"
            value_field: "src/content/blog/{{slug}}.md"
            search_fields:
              - "slug"
              - "title"
            display_fields:
              - "title"
          - *meta_config

      - name: "ecosystem"
        label: "Ecosystem"
        file: "src/content/pages/ecosystem-explorer.md"
        preview_path: "ecosystem-explorer"
        fields:
          - *header_config
          - *meta_config

      - name: "employee-privacy-policy"
        label: "Employee Privacy Policy"
        file: "src/content/pages/employee-privacy-policy.md"
        preview_path: "employee-privacy-policy"
        fields:
          - *header_config
          - *meta_config

      - name: "events"
        label: "Events"
        file: "src/content/pages/events.md"
        preview_path: "events"
        fields:
          - *header_config
          - name: "featured_entry"
            label: "Featured Event"
            widget: "relation"
            collection: "event_entries"
            value_field: "src/content/events/{{slug}}.md"
            search_fields:
              - "slug"
              - "title"
            display_fields:
              - "title"
          - *meta_config

      - name: "filecoin-plus"
        label: "Filecoin Plus"
        file: "src/content/pages/filecoin-plus.md"
        preview_path: "filecoin-plus"
        fields:
          - *header_config
          - *meta_config

      - name: "governance"
        label: "Governance"
        file: "src/content/pages/governance.md"
        preview_path: "governance"
        fields:
          - *header_config
          - *meta_config

      - name: "grants"
        label: "Grants"
        file: "src/content/pages/grants.md"
        preview_path: "grants"
        fields:
          - *header_config
          - name: "featured_grant_graduates"
            label: "Featured Grant Graduates"
            widget: "relation"
            collection: "ecosystem_projects"
            value_field: "src/content/ecosystem-explorer/projects/{{slug}}.md"
            search_fields:
              - "slug"
              - "title"
            display_fields:
              - "title"
            multiple: true
            min: 6
            max: 6
          - *meta_config

      - name: "home"
        label: "Home"
        file: "src/content/pages/home.md"
        fields:
          - *header_config
          - name: "featured_ecosystem_projects"
            label: "Featured Ecosystem Projects"
            widget: "relation"
            collection: "ecosystem_projects"
            value_field: "src/content/ecosystem-explorer/projects/{{slug}}.md"
            search_fields:
              - "slug"
              - "title"
            display_fields:
              - "title"
            multiple: true
            min: 6
            max: 6
          - *meta_config

      - name: "privacy-policy"
        label: "Privacy Policy"
        file: "src/content/pages/privacy-policy.md"
        preview_path: "privacy-policy"
        fields:
          - *header_config
          - *meta_config

      - name: "terms"
        label: "Terms"
        file: "src/content/pages/terms-of-use.md"
        preview_path: "terms-of-use"
        fields:
          - *header_config
          - *meta_config

  - name: "blog_posts"
    label: "Blog Posts"
    label_singular: "Blog Post"
    folder: "src/content/blog/"
    preview_path: "blog/{{slug}}"
    create: true
    extension: "md"
    slug: "{{slug}}"
    fields:
      - name: "title"
        label: "Title"
        widget: "string"
      - *created_on
      - *updated_on
      - *published_on
      - name: "category"
        label: "Category"
        widget: "select"
        options:
          - label: "Ecosystem"
            value: "ecosystem"
          - label: "Events"
            value: "events"
          - label: "Interviews"
            value: "interviews"
          - label: "News"
            value: "news"
          - label: "Reports"
            value: "reports"
          - label: "Use Cases"
            value: "use-cases"
      - name: "description"
        label: "Description"
        widget: "text"
      - *image_config
      - name: "body"
        label: "Content"
        widget: "markdown"
        editor_components:
          - "code-block"
          - "image"
          - "video"
          - "audio"
        required: false
        search_fields:
          - "slug"
          - "title"
        display_fields:
          - "title"
        multiple: true
      - *meta_config

  - name: "ecosystem_projects_categories"
    label: "Ecosystem Projects Categories"
    label_singular: Ecosystem Projects Category
    folder: "src/content/ecosystem-explorer/categories/"
    create: true
    identifier_field: name
    extension: "yml"
    slug: "{{slug}}"
    fields:
      - name: "name"
        label: "Category Name"
        widget: "string"
      - name: "subcategories"
        label: "Subcategories"
        widget: "relation"
        collection: "ecosystem_projects_subcategories"
        search_fields: ["name"]
        value_field: "slug"
        display_fields: ["name"]
        multiple: true

  - name: "ecosystem_projects_subcategories"
    label: "Ecosystem Projects Subcategories"
    label_singular: Ecosystem Projects Subcategory
    folder: "src/content/ecosystem-explorer/subcategories/"
    create: true
    identifier_field: name
    extension: "yml"
    slug: "{{slug}}"
    fields:
      - label: "Subcategory Name"
        name: "name"
        widget: "string"
      - label: "Parent Category"
        name: "parent_category"
        widget: "relation"
        collection: "ecosystem_projects_categories"
        search_fields:
          - name
        value_field: "slug"
        display_fields:
          - name

  - name: ecosystem_projects
    label: Ecosystem Projects
    label_singular: Ecosystem Project
    folder: "src/content/ecosystem-explorer/projects/"
    preview_path: "ecosystem-explorer/{{slug}}"
    create: true
    extension: md
    slug: "{{slug}}"
    fields:
      - name: title
        label: Company Name
        widget: string
      - *created_on
      - *updated_on
      - *published_on
      - name: email
        label: Submitter's Email
        widget: decrypted_widget
      - name: full-name
        label: Submitter's Full Name
        widget: decrypted_widget
      - *image_config
      - name: category
        label: Category
        widget: relation
        collection: "ecosystem_projects_categories"
        value_field: "slug"
        search_fields:
          - name
        display_fields:
          - name
      - name: subcategories
        label: Subcategories
        widget: relation
        collection: "ecosystem_projects_subcategories"
        value_field: "slug"
        search_fields:
          - name
        display_fields:
          - name
        multiple: true
        filter:
          field: "parent_category"
          value: "{{fields.category}}"
      - name: tags
        label: Tags
        widget: hidden
        required: false
        multiple: true
        options:
          - label: "AI Productivity & Utilities"
            value: ai-productivity-and-utilities
          - label: "Arts & Collectibles"
            value: arts-collectibles
          - label: "Bridges & Oracles"
            value: bridges-oracles
          - label: "Climate"
            value: climate
          - label: "Communication & Social"
            value: communication-social
          - label: "DApp"
            value: dapp
          - label: "Data Curation & Monetization"
            value: data-curation-monetization
          - label: "Data Preparation"
            value: data-prep
          - label: "Data Retrieval"
            value: data-retrieval
          - label: "Data Storage & Management"
            value: data-storage-management
          - label: "Decentralized Personal Information Networks"
            value: depin
          - label: "Decentralized Science"
            value: desci
          - label: "Developer Tools"
            value: developer-tools
          - label: "DWeb"
            value: dweb
          - label: "Enterprise"
            value: enterprise
          - label: "Gaming"
            value: gaming
          - label: "GLAM (Galleries, Libraries, Archives, Museums)"
            value: glam
          - label: "Governance, DAOs, & Public Goods"
            value: governance-daos-public-goods
          - label: "GPUs"
            value: gpus
          - label: "Health"
            value: health
          - label: "Infrastructure"
            value: infrastructure
          - label: "Leasing & Staking"
            value: leasing-and-staking
          - label: "Metaverse"
            value: metaverse
          - label: "Network Tools"
            value: network-tools
          - label: "NFTs"
            value: nfts
          - label: "Photo & Video"
            value: photo-video
          - label: "Privacy & Security"
            value: privacy-security
          - label: "Public Data"
            value: public-data
          - label: "Publishing & News"
            value: publishing-news
          - label: "RSS"
            value: rss
          - label: "S3 APIs"
            value: s3-apis
          - label: "Sealing"
            value: sealing
          - label: "Social Impact"
            value: social-impact
          - label: "Space"
            value: space
          - label: "Storage Infrastructure"
            value: storage-infrastructure
          - label: "Storage Provider"
            value: storage-provider
          - label: "Storage Services"
            value: storage-services
          - label: "Storage Software"
            value: storage-software
          - label: "Universities"
            value: universities
          - label: "Wallets, Identity & Authentication"
            value: wallets-identity-authentication
            multiple: true
      - name: description
        label: Short Description
        widget: string
        pattern:
          - "^.{0,160}$"
          - "Must have at most 160 characters."
        hint: "A short description of the project. Maximum 160 characters."
      - name: website
        label: Website
        widget: string
      - name: tech
        label: Technologies Used
        widget: select
        multiple: true
        options:
          - filecoin
          - ipfs
      - name: repo
        label: GitHub Repo
        widget: string
        required: false
      - name: featured-content
        label: Featured Content
        widget: string
        required: false
      - name: twitter
        label: Twitter Handle
        widget: string
        required: false
      - name: video-url
        label: YouTube Video URL
        widget: string
        required: false
      - name: year-joined
        label: Using Filecoin Since
        widget: datetime
        required: false
      - name: body
        label: Long Description
        widget: markdown
        required: false
      - name: news-update
        label: What's New?
        widget: text
        required: false
      - *meta_config

  - name: "event_entries"
    label: "Events"
    folder: "src/content/events/"
    preview_path: "events/{{slug}}"
    label_singular: "Event"
    create: true
    extension: "md"
    slug: "{{slug}}"
    fields:
      - name: "title"
        label: "Title"
        widget: "string"
      - *created_on
      - *updated_on
      - *published_on
      - name: "category"
        label: "Category"
        widget: "select"
        options:
          - label: "Co-Hosted"
            value: "co-hosted"
          - label: "Community"
            value: "community"
          - label: "Hosted"
            value: "hosted"
          - label: "Supported & Sponsored"
            value: "supported-sponsored"
      - name: "location"
        label: "Location"
        widget: "string"
      - name: "start-date"
        label: "Start Date"
        widget: "datetime"
        hint: "First day of event"
      - name: "end-date"
        label: "End Date"
        widget: "datetime"
        required: false
        hint: "Last day of event"
      - name: "description"
        label: "Description"
        widget: "string"
        required: false
      - name: "external-link"
        label: "External Link URL"
        widget: "string"
        required: false
        hint: "External link to the event page"
      - *image_config
      - *meta_config
@mirhamasala mirhamasala added the type: bug code to address defects in shipped code label Aug 27, 2024
@mirhamasala mirhamasala changed the title Please replace with a clear and descriptive title Datetime Widget Displays ‘{{now}}’ Instead of Current Date/Time When now Button is Not Clicked Aug 27, 2024
@mirhamasala
Copy link
Author

Thank you @martinjagodic 🤗

@martinjagodic
Copy link
Member

Fix released in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants