usePlaceholder()
WARNING
Single File Component (SFC) support for Administration extensions is experimental. It is available since Shopware 6.7.16.0. The APIs described on this page can still change without a deprecation. Try it out and tell us what you find, but do not ship an extension built on it to customers or to the Shopware Store until the API is declared stable (planned for 6.9).
import { usePlaceholder } from 'shopware:composables';
function usePlaceholder(): {
placeholder: (entity: Entity<EntityName>, field: keyof Entity<EntityName>, fallbackSnippet: string) => string;
};Reads a translatable field off an entity the way the Administration displays it everywhere else - mostly as the placeholder attribute of a translatable input.
const { placeholder } = usePlaceholder();
const { tWithFallback } = useTranslateWithFallback();
const namePlaceholder = computed(() =>
placeholder(product.value, 'name', tWithFallback('sw-product.detail.placeholderName')),
);Four steps, in order: the field on the entity itself, then the parent language's translation, then the entity's translated object, and the fallback you passed as the last resort. That is what makes an inherited name show up greyed out in a child language instead of showing nothing.
The fallback is returned as it is, so pass translated text, not a snippet key.
Replaces the placeholder mixin.