#Custom Text Field

7 messages · Page 1 of 1 (latest)

frail plover
#

Hello, I'm trying to create a custom text label in v3, but I don't know exactly how to do it correctly.

I have this field in my collection:

  {
    name: 'custom_text',
    type: 'text',
    required: true,
    admin: {
      components: {
        Field: CustomTextField
      }
    }
  },

I don't know how to handle values etc. in that component.

noble laurelBOT
chilly cairn
#

good morning @frail plover

#

You can specify additional props that the functional component will ingest

#
const CustomLabel: React.FC<Props> = (props) => {
  const { htmlFor, label, required = false } = props

  const { i18n } = useTranslation()

  if (label) {
    return (<span>
      {getTranslation(label, i18n)}
      {required && <span className="required">*</span>}
    </span>);
  }

  return null
}
#

So when you intiialize the custom label in your admin config, you can pass data to it