PHP Developer Guide
Other documentationsDemoCommunityGitHub
  • Forest Admin
  • Getting started
    • How it works
    • Quick start
      • Symfony
      • Laravel
    • Create your agent
    • Troubleshooting
    • Migrating legacy agents
      • Pre-requisites
      • Recommendations
      • Migration steps
      • Code transformations
        • API Charts
        • Live Queries
        • Smart Charts
        • Route overrides
        • Smart Actions
        • Smart Fields
        • Smart Relationships
        • Smart Segments
  • Data Sources
    • Getting Started
      • Collection selection
      • Naming conflicts
      • Query interface and Native Queries
        • Fields and projections
        • Filters
        • Aggregations
    • Provided data sources
      • Doctrine
      • Eloquent
        • Polymorphic relationships
    • Write your own
      • Translation strategy
        • Structure declaration
        • Capabilities declaration
        • Read implementation
        • Write implementation
        • Intra-data source Relationships
      • Contribute
  • Agent customization
    • Getting Started
    • Actions
      • Scope and context
      • Result builder
      • Static Forms
      • Dynamic Forms
      • Related data invalidation
    • Charts
      • Value
      • Objective
      • Percentage
      • Distribution
      • Leaderboard
      • Time-based
    • Fields
      • Add fields
      • Move, rename and remove fields
      • Override binary field mode
      • Override writing behavior
      • Override filtering behavior
      • Override sorting behavior
      • Validation
    • Hooks
      • Collection hook
      • Collection override
    • Pagination
    • Plugins
      • Write your own
    • Relationships
      • To a single record
      • To multiple records
      • Computed foreign keys
      • Under the hood
    • Search
    • Segments
  • Frontend customization
    • Smart Charts
      • Create a table chart
      • Create a bar chart
      • Create a cohort chart
      • Create a density map
    • Smart Views
      • Create a Map view
      • Create a Calendar view
      • Create a Shipping view
      • Create a Gallery view
      • Create a custom tinder-like validation view
      • Create a custom moderation view
  • Deploying to production
    • Environments
      • Deploy on AWS
      • Deploy on Heroku
      • Deploy on GCP
      • Deploy on Ubuntu
    • Development workflow
    • Using branches
    • Deploying your changes
    • Forest Admin CLI commands
      • init
      • login
      • branch
      • switch
      • set-origin
      • push
      • environments:create
      • environments:reset
      • deploy
  • Upgrade
    • Laravel agent upgrade to v3
  • Under the hood
    • .forestadmin-schema.json
    • Data Model
      • Typing
      • Relationships
    • Security & Privacy
Powered by GitBook
On this page
  • Primitive types
  • Composite types

Was this helpful?

  1. Under the hood
  2. Data Model

Typing

This is the official documentation of the forestadmin/laravel-forestadmin v2+ and forestadmin/symfony-forestadmin PHP agents.

Fields on Forest Admin can either use Primitive Types or Composite Types.

Primitive types

The primitive types which are supported by Forest Admin are the following:

Forest Admin Type
Language Type

Boolean

Boolean

Date

String with format "1985-10-26T01:22:00-08:00Z" (ISO-8601)

Dateonly

String with format "1985-10-26"

Enum

String

JSON

Any JSON compatible value

Number

Number

Point

Array of 2 Numbers

String

String

Timeonly

String with format "01:22:00"

Uuid

String with uuid v4 format

Composite types

  • Fields using composite types are not sortable and do not implement validation.

  • Fields that are an array of a primitive type only are filterable (depending on the data source).

// Object containing 2 strings
const typeOfObjectWithTwoStrings = { firstName: 'String', lastName: 'String' };

// Array of strings
const typeOfArrayOfStrings = ['String'];

// Array of objects
const typeOfArrayOfObjects = [{ content: 'String' }];

// Object containing a 2d-grid of numbers
const typeOfObjectContainingAGridOfNumbers = { content: [['Number']] };

When using composite types, the data in the UI may not be displayed as you expect!

Composite Type
Example
How it gets displayed

Array of primitive type

[ 'array', 'of', 'strings']

As a custom widget in the edition form

Object

{ title: "the godfather"}

As a nested form in the edition form

Array of object

[{ title: "the shawshank redemption"}]

As a new collection in Related Data section

Array of object (with nested objects)

[{ rating: { kind: 'MPA", value: "PG-13" } }]

JSON editor in the edition form

Anything else

JSON editor in the edition form

If you want to force displaying your data as a new Collection in the Related Data section, but can't because your data model contains nested objects, you may consider typing all nested objects as 'JSON'.

PreviousData ModelNextRelationships

Last updated 1 year ago

Was this helpful?