Show examples in:
    Update a field

    Parameters

    default_value  boolean, null, string, number, object  Optional

    Default value for Field. When field is localized accepts an object of default values with site locales as keys

    label  string  Optional

    The label of the field

    api_key  string  Optional

    Field API key

    localized  boolean  Optional

    Whether the field needs to be multilanguage or not

    validators  object  Optional

    Optional field validations

    appearance  object  Optional

    Field appearance details, plugin configuration and field add-ons

    position  integer  Optional

    Ordering index

    field_type  string  Optional

    Type of input

    hint  string, null  Optional

    Field hint

    fieldset  null, { type: "fieldset", id: fieldset.id }  Optional

    Fieldset linkage

    Returns

    Returns a field resource object.

    Examples

    Example code:
    import { buildClient } from '@datocms/cma-client-node';
    async function run() {
    const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
    const fieldIdOrApiKey = 'blog_post::title';
    const field = await client.fields.update(fieldIdOrApiKey, {
    default_value: {
    en: 'A default value',
    it: 'Un valore di default'
    },
    label: 'Title',
    api_key: 'title',
    localized: true,
    validators: {
    required: {}
    },
    appearance: {
    editor: 'single_line',
    parameters: {
    heading: false
    },
    addons: [
    {
    id: '1234',
    field_extension: 'lorem_ipsum',
    parameters: {}
    }
    ]
    },
    position: 1,
    field_type: 'string',
    hint: 'This field will be used as post title',
    fieldset: null
    });
    console.log(field);
    }
    run();
    Returned output:
    {
    id: '124',
    label: 'Title',
    field_type: 'string',
    localized: true,
    default_value: {
    en: 'A default value',
    it: 'Un valore di default'
    },
    api_key: 'title',
    hint: 'This field will be used as post title',
    validators: {
    required: {}
    },
    appearance: {
    editor: 'single_line',
    parameters: {
    heading: false
    },
    addons: [
    {
    id: '1234',
    field_extension: 'lorem_ipsum',
    parameters: {}
    }
    ]
    },
    position: 1,
    item_type: {
    type: 'item_type',
    id: '44'
    },
    fieldset: null
    }