Skip to content
13 changes: 9 additions & 4 deletions src/components/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Field = ({
disabled = false,
formHasErrors = false,
id,
labelsAsPlaceholders,
}) => {
const intl = useIntl();

Expand All @@ -57,21 +58,24 @@ const Field = ({
<TextWidget
id={name}
name={name}
title={label}
title={labelsAsPlaceholders ? '' : label}
placeholder={labelsAsPlaceholders ? label : ''}
description={description}
required={required}
onChange={onChange}
value={value}
isDisabled={disabled}
invalid={isInvalid().toString()}
columns={labelsAsPlaceholders ? 1 : undefined}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
)}
{field_type === 'textarea' && (
<TextareaWidget
id={name}
name={name}
title={label}
title={labelsAsPlaceholders ? '' : label}
placeholder={labelsAsPlaceholders ? label : ''}
description={description}
required={required}
onChange={onChange}
Expand All @@ -86,7 +90,7 @@ const Field = ({
<SelectWidget
id={name}
name={name}
title={label}
title={labelsAsPlaceholders ? '' : label}
description={description}
getVocabulary={() => {}}
getVocabularyTokenTitle={() => {}}
Expand Down Expand Up @@ -185,7 +189,8 @@ const Field = ({
<EmailWidget
id={name}
name={name}
title={label}
title={labelsAsPlaceholders ? '' : label}
placeholder={labelsAsPlaceholders ? label : ''}
description={description}
required={required}
onChange={onChange}
Expand Down
2 changes: 2 additions & 0 deletions src/components/FormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const FormView = ({
disabled
valid
formHasErrors={formErrors?.length > 0}
labelsAsPlaceholders={data.labelsAsPlaceholders}
/>
</Grid.Column>
</Grid.Row>
Expand Down Expand Up @@ -155,6 +156,7 @@ const FormView = ({
}
valid={isValidField(name)}
formHasErrors={formErrors?.length > 0}
labelsAsPlaceholders={data.labelsAsPlaceholders}
/>
</Grid.Column>
</Grid.Row>
Expand Down
5 changes: 5 additions & 0 deletions src/formSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default () => {
'captcha',
'store',
'send',
'labelsAsPlaceholders',
],
},
],
Expand Down Expand Up @@ -107,6 +108,10 @@ export default () => {
type: 'boolean',
title: intl.formatMessage(messages.send),
},
labelsAsPlaceholders: {
type: 'boolean',
title: 'Use labels as placeholders',
},
},
required: ['default_to', 'default_from', 'default_subject'],
};
Expand Down