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

Hey,

This doesn’t seem to be working. We have the following custom input in the configuration for the witholding_tax template. But it doesn’t print anything in the export.

{% input period.custom.contact.name as:text default:user.name assign:contact_name %}

Hi Jasper

This is related to this question a from a while back.

The default name is not being displayed in export, because the user drop can’t be accessed in the export styles.

Kind regards
Robbe

Hi Robbe,

Ok, I get it now.
I have added an if-statement to print the ‘result’ when the default is used.
This did the trick for the export.

Is there a list of drops that cannot be accessed in the export styles?
I didn’t seem to find somthing like it in the STL documentation.

Thank you again for the feedback.

Kind regards
Jasper