Score:0

การเพิ่มฟิลด์แบบกำหนดเองที่สร้างโดย drush ไปยังฟิลด์ที่มีบนโหนด

ธง us

ฉันมีโมดูลแบบกำหนดเองอยู่แล้วบนเว็บไซต์ D9 ของฉัน และฉันจำเป็นต้องทำการเปลี่ยนแปลงบางอย่างภายในนั้น ฉันต้องการเพิ่มฟิลด์ (บูลีน) ในการแก้ไขหน้าประเภทเนื้อหาโดยไม่ต้องทำด้วยตนเอง

ดังนั้นฉันจึงต้องการให้ฟิลด์ของฉันพร้อมใช้งานที่นี่ /admin/structure/types/manage/mycontenttype/fields/add-field

ใน CLI ของฉัน ฉันได้รันคำสั่งนี้ drush สร้างฟิลด์ซึ่งให้ไฟล์เหล่านั้นแก่ฉัน:

  โมดูล/กำหนดเอง/mymdule/config/schema/calcul.schema.yml
  โมดูล/กำหนดเอง/mymdule/css/calcul-ajout-widget.css
  โมดูล/กำหนดเอง/mymdule/calcul.libraries.yml
  โมดูล/กำหนดเอง/mymdule/src/Plugin/Field/FieldFormatter/AjoutDefaultFormatter.php
  โมดูล/กำหนดเอง/mymdule/src/Plugin/Field/FieldType/AjoutItem.php
  โมดูล/กำหนดเอง/mymdule/src/Plugin/Field/FieldWidget/AjoutWidget.php

หลังจากนั้นฉันก็วิ่ง drush updbแต่มันบอกว่าฐานข้อมูลเป็นปัจจุบันแล้ว แต่ฉันไม่เห็นสนามของฉันที่นี่ นอกจากนี้ คำสั่งไม่ได้ถามฉันว่าควรเชื่อมโยงประเภทเอนทิตีใดกับฟิลด์นี้

ความคิดใด ๆ ? ฉันทำอะไรผิด ?

ป้อนคำอธิบายรูปภาพที่นี่

leymannx avatar
ne flag
Why don't you use configuration management?
leymannx avatar
ne flag
Does this answer your question? [add field to user in hook\_update\_n](https://drupal.stackexchange.com/questions/307964/add-field-to-user-in-hook-update-n)
mt.i.1 avatar
us flag
@leymannx because I'd like to do it programmaticaly, if it's possible. I have a certain amount of entity type, so it could be time consuming... and I don't think your solution is the same than my problem
4uk4 avatar
cn flag
The drush command is for modules which want to define a new field type. A prominent example is the [Address](https://www.drupal.org/project/address) module. Once you have installed such a module you see the field type on the left side, not the right. The right select box is filled with fields already used in other content types so that you can re-use them to save database tables.
mt.i.1 avatar
us flag
Oh, ok thanks for the precison ! Indeed, I see my left select dropdow.
mt.i.1 avatar
us flag
บางทีคุณควรโพสต์ความคิดเห็นของคุณเป็นคำตอบ

โพสต์คำตอบ

คนส่วนใหญ่ไม่เข้าใจว่าการถามคำถามมากมายจะปลดล็อกการเรียนรู้และปรับปรุงความสัมพันธ์ระหว่างบุคคล ตัวอย่างเช่น ในการศึกษาของ Alison แม้ว่าผู้คนจะจำได้อย่างแม่นยำว่ามีคำถามกี่ข้อที่ถูกถามในการสนทนา แต่พวกเขาไม่เข้าใจความเชื่อมโยงระหว่างคำถามและความชอบ จากการศึกษาทั้ง 4 เรื่องที่ผู้เข้าร่วมมีส่วนร่วมในการสนทนาด้วยตนเองหรืออ่านบันทึกการสนทนาของผู้อื่น ผู้คนมักไม่ตระหนักว่าการถามคำถามจะมีอิทธิพลหรือมีอิทธิพลต่อระดับมิตรภาพระหว่างผู้สนทนา