# Class Field

Field Class

#### Hierarchy

- Field

#### Implements

- AbstractField

- Defined in saltcorn-data/models/field.ts:67

#####
Index

### Constructors

constructor

### Properties

attributes
calculated
class
default?
description?
disabled
exclude_from_mobile?
expression?
fieldview?
fieldviewObj?
help?
hidden
id?
in_auto_save?
input_type
is_fkey
is_unique
label
name
options?
parent_field?
postText?
preset_options?
primary_key
refname
reftable?
reftable_name?
reftype?
required
showIf?
sourceURL?
stored
sublabel?
tab?
table?
table_id?
type?
typename?
validator

### Accessors

form_name
listKey
multipartFormData
on_delete_sql
presets
pretty_type
sql_bare_type
sql_type
toBuilder
toJson
type_name

### Methods

add_unique_constraint
alter_sql_type
delete
distinct_values
enable_fkey_constraint
fill_fkey_options
fill_table
generate
remove_unique_constraint
set_calc_joinfields
showIfEnabled
toggle_not_null
update
validate
create
find
findOne
getTypeAttributes
labelToName
nameToLabel
select_options_query

## Constructors

### constructor

- new Field(o): Field

- Constructor

  #### Parameters

  - ##### o: Field | FieldCfg

  #### Returns Field

  - Defined in saltcorn-data/models/field.ts:114

## Properties

### attributes

attributes: GenObj

Implementation of AbstractField.attributes

- Defined in saltcorn-data/models/field.ts:100

### calculated

calculated: boolean

- Defined in saltcorn-data/models/field.ts:88

### class

class: string

- Defined in saltcorn-data/models/field.ts:75

### `Optional` default

default?: string

- Defined in saltcorn-data/models/field.ts:77

### `Optional` description

description?: string

- Defined in saltcorn-data/models/field.ts:79

### disabled

disabled: boolean

- Defined in saltcorn-data/models/field.ts:87

### `Optional` exclude_from_mobile

exclude_from_mobile?: boolean

- Defined in saltcorn-data/models/field.ts:104

### `Optional` expression

expression?: string

- Defined in saltcorn-data/models/field.ts:91

### `Optional` fieldview

fieldview?: string

Implementation of AbstractField.fieldview

- Defined in saltcorn-data/models/field.ts:70

### `Optional` fieldviewObj

fieldviewObj?: FieldView

- Defined in saltcorn-data/models/field.ts:105

### `Optional` help

help?: {
context?: Row;
dynContext?: string[];
topic: string;
}

#### Type declaration

- ##### `Optional` context?: Row

- ##### `Optional` dynContext?: string[]

- ##### topic: string

- Defined in saltcorn-data/models/field.ts:82

### hidden

hidden: boolean

- Defined in saltcorn-data/models/field.ts:86

### `Optional` id

id?: number

Implementation of AbstractField.id

- Defined in saltcorn-data/models/field.ts:76

### `Optional` in_auto_save

in_auto_save?: boolean

- Defined in saltcorn-data/models/field.ts:103

### input_type

input_type: InputType

Implementation of AbstractField.input_type

- Defined in saltcorn-data/models/field.ts:94

### is_fkey

is_fkey: boolean

Implementation of AbstractField.is_fkey

- Defined in saltcorn-data/models/field.ts:93

### is_unique

is_unique: boolean

- Defined in saltcorn-data/models/field.ts:85

### label

label: string

Implementation of AbstractField.label

- Defined in saltcorn-data/models/field.ts:68

### name

name: string

Implementation of AbstractField.name

- Defined in saltcorn-data/models/field.ts:69

### `Optional` options

options?: any

- Defined in saltcorn-data/models/field.ts:83

### `Optional` parent_field

parent_field?: string

- Defined in saltcorn-data/models/field.ts:73

### `Optional` postText

postText?: string

- Defined in saltcorn-data/models/field.ts:74

### `Optional` preset_options

preset_options?: string[]

- Defined in saltcorn-data/models/field.ts:106

### primary_key

primary_key: boolean

Implementation of AbstractField.primary_key

- Defined in saltcorn-data/models/field.ts:89

### refname

refname: string = ""

- Defined in saltcorn-data/models/field.ts:98

### `Optional` reftable

reftable?: Table

- Defined in saltcorn-data/models/field.ts:99

### `Optional` reftable_name

reftable_name?: string

Implementation of AbstractField.reftable_name

- Defined in saltcorn-data/models/field.ts:95

### `Optional` reftype

reftype?: string | Type

- Defined in saltcorn-data/models/field.ts:97

### required

required: boolean

Implementation of AbstractField.required

- Defined in saltcorn-data/models/field.ts:84

### `Optional` showIf

showIf?: {
[field_name: string]: string | boolean | string[];
}

#### Type declaration

- ##### [field_name: string]: string | boolean | string[]

- Defined in saltcorn-data/models/field.ts:72

### `Optional` sourceURL

sourceURL?: string

Implementation of AbstractField.sourceURL

- Defined in saltcorn-data/models/field.ts:92

### stored

stored: boolean

- Defined in saltcorn-data/models/field.ts:90

### `Optional` sublabel

sublabel?: string

- Defined in saltcorn-data/models/field.ts:78

### `Optional` tab

tab?: string

- Defined in saltcorn-data/models/field.ts:96

### `Optional` table

table?: null | Table

- Defined in saltcorn-data/models/field.ts:102

### `Optional` table_id

table_id?: number

- Defined in saltcorn-data/models/field.ts:101

### `Optional` type

type?: string | Type

- Defined in saltcorn-data/models/field.ts:80

### `Optional` typename

typename?: string

- Defined in saltcorn-data/models/field.ts:81

### validator

validator: ((value, whole_rec?) => undefined | string | boolean)

#### Type declaration

- - (value, whole_rec?): undefined | string | boolean

  - #### Parameters

    - ##### value: any

    - ##### `Optional` whole_rec: Row

    #### Returns undefined | string | boolean

- Defined in saltcorn-data/models/field.ts:71

## Accessors

### form_name

- get form_name(): string

- ???

  #### Returns string

  Implementation of AbstractField.form_name

  - Defined in saltcorn-data/models/field.ts:270

### listKey

- get listKey(): any

- #### Returns any

  - Defined in saltcorn-data/models/field.ts:1105

### multipartFormData

- get multipartFormData(): boolean

- #### Returns boolean

  - Defined in saltcorn-data/models/field.ts:704

### on_delete_sql

- get on_delete_sql(): string

- #### Returns string

  - Defined in saltcorn-data/models/field.ts:584

### presets

- get presets(): null | {
  LoggedIn: ((__namedParameters) => boolean);
  }

- #### Returns null | {
  LoggedIn: ((__namedParameters) => boolean);
  }

  - Defined in saltcorn-data/models/field.ts:1117

### pretty_type

- get pretty_type(): string

- #### Returns string

  Implementation of AbstractField.pretty_type

  - Defined in saltcorn-data/models/field.ts:638

### sql_bare_type

- get sql_bare_type(): string

- #### Returns string

  - Defined in saltcorn-data/models/field.ts:648

### sql_type

- get sql_type(): string

- #### Returns string

  - Defined in saltcorn-data/models/field.ts:596

### toBuilder

- get toBuilder(): any

- To Json

  #### Returns any

  - Defined in saltcorn-data/models/field.ts:225

### toJson

- get toJson(): any

- To Json

  #### Returns any

  - Defined in saltcorn-data/models/field.ts:198

### type_name

- get type_name(): undefined | string

- #### Returns undefined | string

  Implementation of AbstractField.type_name

  - Defined in saltcorn-data/models/field.ts:260

## Methods

### add_unique_constraint

- add_unique_constraint(): Promise<void>

- #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:789

### alter_sql_type

- alter_sql_type(new_field): Promise<void>

- #### Parameters

  - ##### new_field: Field

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:831

### delete

- delete(): Promise<void>

- #### Returns Promise<void>

  #### Throws

  - Defined in saltcorn-data/models/field.ts:1131

### distinct_values

- distinct_values(req?, where?, only_present?): Promise<{
  jsvalue?: boolean;
  label: string;
  value: string;
  }[]>

- Distinct Values

  #### Parameters

  - ##### `Optional` req: any

  - ##### `Optional` where: Where

  - ##### `Optional` only_present: boolean

  #### Returns Promise<{
  jsvalue?: boolean;
  label: string;
  value: string;
  }[]>

  - Defined in saltcorn-data/models/field.ts:498

### enable_fkey_constraint

- enable_fkey_constraint(table): Promise<void>

- #### Parameters

  - ##### table: Table

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:1169

### fill_fkey_options

- fill_fkey_options(force_allow_none?, where0?, extraCtx?, optionsQuery?, formFieldNames?, existingValue?, user?): Promise<void>

- Fills 'this.options' with values available via foreign key Could be used for in a
  to select a user

  #### Parameters

  - ##### `Optional` force_allow_none: boolean = false

  - ##### `Optional` where0: Where

  - ##### extraCtx: any = {}

  - ##### `Optional` optionsQuery: any

    remote/local query to load rows from 'reftable_name'

  - ##### `Optional` formFieldNames: string[]

  - ##### `Optional` existingValue: any

  - ##### `Optional` user: any

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:318

### fill_table

- fill_table(): void

- #### Returns void

  - Defined in saltcorn-data/models/field.ts:938

### generate

- generate(): Promise<any>

- #### Returns Promise<any>

  - Defined in saltcorn-data/models/field.ts:675

### remove_unique_constraint

- remove_unique_constraint(): Promise<void>

- #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:797

### set_calc_joinfields

- set_calc_joinfields(): Promise<void>

- #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:947

### showIfEnabled

- showIfEnabled(whole_rec): boolean

- #### Parameters

  - ##### whole_rec: any

  #### Returns boolean

  - Defined in saltcorn-data/models/field.ts:694

### toggle_not_null

- toggle_not_null(not_null): Promise<void>

- #### Parameters

  - ##### not_null: boolean

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:811

### update

- update(v): Promise<void>

- #### Parameters

  - ##### v: Partial<Field> | Partial<FieldCfg>

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/field.ts:1017

### validate

- validate(whole_rec): ResultMessage

- #### Parameters

  - ##### whole_rec: any

  #### Returns ResultMessage

  - Defined in saltcorn-data/models/field.ts:713

### `Static` create

- create(fld, bare?, id?): Promise<Field>

- #### Parameters

  - ##### fld: Field | FieldCfg

  - ##### bare: boolean = false

  - ##### `Optional` id: string

    optional id, if set, no '_sc_fields' entry is inserted

  #### Returns Promise<Field>

  - Defined in saltcorn-data/models/field.ts:1197

### `Static` find

- find(where?, selectopts?): Promise<Field[]>

- #### Parameters

  - ##### `Optional` where: Where

  - ##### `Optional` selectopts: SelectOptions = ...

  #### Returns Promise<Field[]>

  - Defined in saltcorn-data/models/field.ts:762

### `Static` findOne

- findOne(where): Promise<Field>

- #### Parameters

  - ##### where: Where

  #### Returns Promise<Field>

  - Defined in saltcorn-data/models/field.ts:781

### `Static` getTypeAttributes

- getTypeAttributes(typeattribs?, table_id?): any

- #### Parameters

  - ##### `Optional` typeattribs: any

  - ##### `Optional` table_id: number

  #### Returns any

  - Defined in saltcorn-data/models/field.ts:1313

### `Static` labelToName

- labelToName(label): string

- Label 2 Name

  #### Parameters

  - ##### label: string

  #### Returns string

  - Defined in saltcorn-data/models/field.ts:252

### `Static` nameToLabel

- nameToLabel(label): string

- #### Parameters

  - ##### label: string

  #### Returns string

  - Defined in saltcorn-data/models/field.ts:256

### `Static` select_options_query

- select_options_query(table_name, where, attributes, extra_joinfields?, user?): Promise<any>

- #### Parameters

  - ##### table_name: string

  - ##### where: string

  - ##### attributes: any

  - ##### extra_joinfields: any = {}

  - ##### `Optional` user: any

  #### Returns Promise<any>

  - Defined in saltcorn-data/models/field.ts:275

Generated using TypeDoc