Added custom fields additional props

This commit is contained in:
francesco
2020-05-04 17:45:55 +02:00
parent d73cbdac7a
commit f7619d7715
12 changed files with 48 additions and 15 deletions

View File

@@ -8,14 +8,20 @@ import {
import React, { ReactElement } from "react";
import { CMSFieldProps } from "firecms";
interface CustomLargeTextFieldProps extends CMSFieldProps<string> {
rows: number
}
export default function CustomLargeTextField({
property,
field,
rows,
form: { isSubmitting, errors, touched, setFieldValue },
...props
}: CMSFieldProps<string>)
}: CustomLargeTextFieldProps)
: ReactElement {
console.log(props);
const fieldError = getIn(errors, field.name);
const showError = getIn(touched, field.name) && !!fieldError;
@@ -32,7 +38,7 @@ export default function CustomLargeTextField({
<InputLabel>{property.title || field.name}</InputLabel>
<Input
multiline
rows={4}
rows={rows}
defaultValue={value}
onChange={(evt) => setFieldValue(
field.name,

View File

@@ -187,6 +187,9 @@ const blogSchema: EntitySchema = {
validation: { required: true },
dataType: "string",
customField: CustomLargeTextField,
customFieldProps: {
rows: 5
},
includeInListView: false
},
content: {
@@ -194,7 +197,7 @@ const blogSchema: EntitySchema = {
validation: { required: true },
dataType: "array",
of: {
dataType: "string",
dataType: "string"
},
includeInListView: false
},