Skip to content

Feature Request: Ability to dynamically set defaults in settings tag #199

@ishields

Description

@ishields

When rendering settings it is currently not possible to send a dynamic default in.

Given this:

= block.setting_tag :title, html_tag: :h4

If title is empty, it will use the default in the yml, but you can't dynamically set this default currently. For example - this block is a custom collection and I'd like to set a default based on that collection.

I found a hacky way to do this like this but it's hard to know if this could cause other issues in the editor:

- if block.settings.title.content.blank?
   - block.settings.title.content = "My dynamic default - #{block.settings.store.item.display_name}"
= block.setting_tag :title, html_tag: :h4

With the above code if it's not defined it will render the name of the collection item (in this case a store)

A better solution might be something like this:

= block.setting_tag :title, html_tag: :h4, default_content: "My dynamic default - #{block.settings.store.item.display_name}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions