From 4a10c68e4a529c29338d6fcb8767501dbda5d4be Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Tue, 6 Oct 2020 20:28:52 +0200 Subject: [PATCH 1/4] Allow default values for Fields in new Content --- templates/_partials/fields/_base.html.twig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig index 33944aec8..f3d667451 100644 --- a/templates/_partials/fields/_base.html.twig +++ b/templates/_partials/fields/_base.html.twig @@ -78,6 +78,11 @@ {% if value is string %} {% set value = value|replace({'{{': "{\xE2\x80\x8B{", '}}': "}\xE2\x80\x8B}" }) %} {% endif %} + + {# Set a default, for example when an extension requests `/bolt/new/entries?field-title=Foo+Bar #} + {% if not record.id and not value %} + {% set value = app.request.get(id) %} + {% endif %} {% endif %} {# Set the class #} From 4b4e6b0c98cc037c992c9ee5d488dcab7b0407b1 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 7 Oct 2020 11:07:41 +0200 Subject: [PATCH 2/4] Add `|default` --- config/bolt/contenttypes.yaml | 16 ++++++++++++++++ symfony.lock | 3 +++ templates/_partials/fields/_base.html.twig | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config/bolt/contenttypes.yaml b/config/bolt/contenttypes.yaml index bb6587df9..68e3fb7e6 100644 --- a/config/bolt/contenttypes.yaml +++ b/config/bolt/contenttypes.yaml @@ -45,6 +45,22 @@ homepage: icon_many: "fa:home" icon_one: "fa:home" +dummies: + name: Dummies + singular_name: Dummy + fields: + title: + type: text + slug: + type: slug + uses: title + veld: + type: collection + fields: + foo: + type: html + icon_many: "fa:viruses" + icon_one: "fa:virus" # Pages can be used for the more 'static' pages on your site. This content-type # has a 'templateselect' field, which allows you to override the record_template diff --git a/symfony.lock b/symfony.lock index 884bf64fc..db9f18a9b 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1074,6 +1074,9 @@ "symplify/smart-file-system": { "version": "v7.2.2" }, + "symplify/symplify-kernel": { + "version": "8.3.30" + }, "theseer/tokenizer": { "version": "1.1.3" }, diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig index f3d667451..ee2e3de93 100644 --- a/templates/_partials/fields/_base.html.twig +++ b/templates/_partials/fields/_base.html.twig @@ -80,7 +80,7 @@ {% endif %} {# Set a default, for example when an extension requests `/bolt/new/entries?field-title=Foo+Bar #} - {% if not record.id and not value %} + {% if not record.id|default() and not value %} {% set value = app.request.get(id) %} {% endif %} {% endif %} From 36c4875ae7c251f3563f3e8807ef1c204ab0a7c1 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 7 Oct 2020 11:13:45 +0200 Subject: [PATCH 3/4] Reverting stuff that shouldn't've been part of previous commit --- config/bolt/contenttypes.yaml | 17 ----------------- symfony.lock | 3 --- 2 files changed, 20 deletions(-) diff --git a/config/bolt/contenttypes.yaml b/config/bolt/contenttypes.yaml index 68e3fb7e6..b2d2abce2 100644 --- a/config/bolt/contenttypes.yaml +++ b/config/bolt/contenttypes.yaml @@ -45,23 +45,6 @@ homepage: icon_many: "fa:home" icon_one: "fa:home" -dummies: - name: Dummies - singular_name: Dummy - fields: - title: - type: text - slug: - type: slug - uses: title - veld: - type: collection - fields: - foo: - type: html - icon_many: "fa:viruses" - icon_one: "fa:virus" - # Pages can be used for the more 'static' pages on your site. This content-type # has a 'templateselect' field, which allows you to override the record_template # setting for an individual page. diff --git a/symfony.lock b/symfony.lock index db9f18a9b..884bf64fc 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1074,9 +1074,6 @@ "symplify/smart-file-system": { "version": "v7.2.2" }, - "symplify/symplify-kernel": { - "version": "8.3.30" - }, "theseer/tokenizer": { "version": "1.1.3" }, From e317ccfb6fad4b5799f618113f37b5d616a900cd Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 7 Oct 2020 11:14:13 +0200 Subject: [PATCH 4/4] Update contenttypes.yaml --- config/bolt/contenttypes.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/bolt/contenttypes.yaml b/config/bolt/contenttypes.yaml index b2d2abce2..bb6587df9 100644 --- a/config/bolt/contenttypes.yaml +++ b/config/bolt/contenttypes.yaml @@ -45,6 +45,7 @@ homepage: icon_many: "fa:home" icon_one: "fa:home" + # Pages can be used for the more 'static' pages on your site. This content-type # has a 'templateselect' field, which allows you to override the record_template # setting for an individual page.