Is it possible to add default values to fields like title, url appendix /slug, date (like: next sunday) and such, so that the fields in the dialog are pre-filled? I tried a few things in the blueprint, but they didn’t work. See example with default for title below.
create:
title:
label: Titel
default: Wochenrückblick KW/2023
fields:
- published
- subtitle
redirect: true
status: draft
published is a datefield, not sure if i can use anything like “next sunday” in here.
published:
label: Published on
width: 1/2
type: date
display: DD.MM.YYYY
time: true
display: HH:mm
step: 1
default: now + 1 day
width: 1/1
notation: 24
Anyway, the field shows up in the dialog but it’s empty. Would be awesome if it was prefilled.
Trying to do the same thing here. I need to use a query that picks a date from the parent page. The default works on the actual page, but not in the create dialog.
I also need to correct my previous comment:
I thought it was possible to use queries for default values, but it does not seem to work anywhere. For comparison queries do work in the help text but not for default. Would be super useful if we could use queries so it can be based on something the user previously has entered.
If this is something that is not on the roadmap, is their any way of manipulating the default values before the dialog is displayed, with a custom model, hook or something…? @texnixe
Might be possible if you create the blueprint via PHP, but only if the parent page is known, because in programmable blueprints you don’t have access to the current page.
The update is nice, but i think this still doesn’t work for me, cause i can’t see a way to get the date and calendarweek of “next sunday” which i need in the slug and title. I built a workaround that is okay for me: a new template that does all stuff (get the date of next sunday and such) and creates a new page in the place where it should be and with all the defaults i need. The template is assigned to a hidden page i open from the panel. Adding a button to do so could be done to save 1 or 2 clicks but it was too much overload for such a simple task imho.
Might be possible if you create the blueprint via PHP, but only if the parent page is known, because in programmable blueprints you don’t have access to the current page.
Ok this is interesting… I’ve never done blueprints this way, let’s see if I have time to test. But… I need to fetch the date of a sibling “event” page, do some work with that, and use as default for the page being created. The parent page is a “tour” page and there are multiple. So I guess it won’t work?
Another option: Overwrite the date field with your own, changing the default property to support query strings. Basically like here with the number field: Dynamic default number field - #2 by texnixe
The problem is that the field you want to use is not present in the list of fields, so you have to add the published field to the list of fields within the create dialog.
okay, i see. Thank you. This works for title and slug now, but not for the other custom field “subtitle”, i tried adding it to the fields, but in the dialog it’s empty
Because this feature only works for title and slug, not for other fields. If you want to prefill other fields, it probably makes more sense to create a page model.