CASE: when to use placeholder or default?

When you create a custom object, you’ll have the option to add the following tags:

placeholder

{% input custom.the_namespace.the_key placeholder:"enter name here" %}

This guides the user what to do with the object (to fill it with a name):
45

The “enter name here” will never be displayed too in an export. So if you don’t fill a value in the object, nothing will be displayed in the export. You could say the placeholder-tag has only use for input-mode.

default

{% input custom.the_namespace.the_key default:"Michael Jordan" %}

This tag is meant for the output-mode. In input-mode the value will also be displayed (so the user doesn’t have to fill it in), but in export that value will also be shown:

input

46

output

30

:warning: Beware though! A default-tag never will fill the object with the default. So in this example the object custom.the_namespace.the_key is empty! But, in export it will show something. Very important to understand this matter
The reason for this, is that an input is only made possible by Silverfin; in standard Liquid (Shopify made this) this isn’t even possible. Only when you actually put something in the object, the object will no longer be empty (and a default-tag doesn’t fill the object at all!) :warning:

If any questions, plz shoot

1 Like

How can you use the value of the default in an other object?

exemple:

op datum van {% input period.custom.letter.date as:date default:period.custom.av.datum %}

Gedaan te {% input.custom.opdrachtbrief.gemeente %} op {{ period.custom.letter.date }}


Hi @EHE1

“default” can also be used when printing or creating new variables, so not only on inputs.
In this example you can create a new local variable that holds the input and the default.

{% assign letter_date = period.custom.letter.date | default:period.custom.av.datum %}
Gedaan te {% input.custom.opdrachtbrief.gemeente %} op {{ letter_date }}

Alternatively, this would also work:

Gedaan te {% input.custom.opdrachtbrief.gemeente %} op {{ period.custom.letter.date | default:period.custom.av.datum }}

Though I recommend using the first approach with the local variable.

Kind regards,
Romy