Skip to content

อ้างอิง field ​

ตัวเลือกทั้งหมดของ field มีเทสต์ตรวจกับ type ใน @easy-cms/core หน้าตาในหน้า admin และวิธีจัดเก็บดูได้ที่ Fields

ตัวเลือกของทุก field ​

ตัวเลือกType
namestringจำเป็น เป็นชื่อตัวแปรของ JavaScript และไม่ซ้ำกับ field ข้างเคียง
typeดูประเภทจำเป็น
labelstring | { en, th }ค่าเริ่มต้นคือชื่อ field ที่แปลงให้อ่านง่าย
requiredbooleanต้องมีค่า (ไม่ตรวจตอนบันทึกฉบับร่าง)
uniquebooleanเอกสารสองรายการใช้ค่าซ้ำกันไม่ได้ (field ระดับบนสุด)
indexbooleanสร้าง index ในฐานข้อมูล
defaultValueค่าของ fieldใช้เมื่อสร้างเอกสารโดยไม่มีค่านี้
validate(value, { data, operation }) => true | stringตรวจเอง เป็น async ได้
access{ read?, update? }สิทธิ์ระดับ field
hiddenbooleanถูกจัดเก็บ แต่ไม่ถูกส่งคืนและไม่รับเป็น input
localizedbooleanเก็บค่าแยกตามภาษา (ต้องมี localization)
position'sidebar'แสดงในแถบข้างของหน้าแก้ไข (field ระดับบนสุด)
adminFieldAdminadmin components ดูด้านล่าง

admin ​

ตัวเลือกType
componentAdminComponentWeb Component แทนช่องกรอก Admin components
afterAdminComponent[]component ที่แสดงใต้ field

AdminComponent คือชื่อ tag ที่ขึ้นต้นด้วย ecms- หรือ { tag, props }

ประเภท ​

ประเภทค่าตัวเลือกเพิ่มเติม
textstringminLength, maxLength
textareastringminLength, maxLength
emailstring (ตัวพิมพ์เล็ก)
numbernumbermin, max
booleanboolean
datestring แบบ ISO 8601
selectหนึ่งตัวเลือก หรือ array เมื่อใช้ hasManyoptions, hasMany
slugstring ที่ปลอดภัยสำหรับ URL และไม่ซ้ำfrom
jsonJSON ใดก็ได้
richTextJSON ของ Tiptapดู Rich text
uploadid ของเอกสาร media
relationshipid ของเอกสารto, hasMany
arrayแถวที่มี id และ field ย่อยfields, minRows, maxRows
groupobjectfields
blocksแถวหลายชนิด มี blockTypeblocks, minRows, maxRows

text และ textarea ​

ตัวเลือกType
minLengthnumberจำนวนตัวอักษรน้อยที่สุด
maxLengthnumberจำนวนตัวอักษรมากที่สุด หน้า admin จะพิมพ์เกินไม่ได้

number ​

ตัวเลือกType
minnumberค่าน้อยที่สุด
maxnumberค่ามากที่สุด

select ​

ตัวเลือกType
options(string | { label, value })[]จำเป็น ตัวเลือก label เป็น { en, th } ได้
hasManybooleanเลือกได้หลายตัว (checkbox) ค่าเป็น array

slug ​

ตัวเลือกType
fromstringfield แบบ text ข้างเคียงที่ใช้สร้าง slug เมื่อยังว่าง
uniqueWithinstringfield ข้างเคียง (เช่น parent): slug ห้ามซ้ำเฉพาะเอกสารที่มีค่าใน field นั้นเหมือนกัน

relationship ​

ตัวเลือกType
tostringจำเป็น slug ของ collection ปลายทาง
hasManybooleanหลายเอกสาร ค่าเป็น array
filterOptions({ id, user, cms }) => Where | trueเอกสารใดที่เลือกได้ ช่องเลือกใน admin แสดงเฉพาะเอกสารเหล่านี้ และตรวจซ้ำตอนบันทึก

array ​

ตัวเลือกType
fieldsField[]จำเป็น field ของแต่ละแถว
minRowsnumberจำนวนแถวน้อยที่สุด
maxRowsnumberจำนวนแถวมากที่สุด

group ​

ตัวเลือกType
fieldsField[]จำเป็น field ข้างใน

blocks ​

ตัวเลือกType
blocksBlock[]จำเป็น ชนิดของแถว ดู Block
minRowsnumberจำนวนแถวน้อยที่สุด
maxRowsnumberจำนวนแถวมากที่สุด

Block ​

ตัวเลือกType
slugstringจำเป็น เก็บในแต่ละแถวเป็น blockType
labels{ singular?, plural? }ชื่อในหน้า admin
fieldsField[]จำเป็น field ของ block

เผยแพร่ภายใต้สัญญาอนุญาต MIT