في ملف المخطط الخاص بالقالب ، أود استخدام حقل مكرر / قائمة ،
يحتوي على حقل محدد مع خيارات ،
والحقول الشرطية التي تقيم اختيار المستخدمين لعرض الحقول وفقًا لذلك.
أرغب في استخدام هذا للمقالات الطويلة ، حيث يمكن للمستخدم إضافة / تبديل أنواع مختلفة من المكونات
كيف أقوم بتعيين شرط على قيمة الحقل المحدد (في التكرار)؟
نظرًا لأن الكود الآن ، يكون التحديد فقط مرئيًا وليس للشروط الشرطية أي تأثير.
header.field.selection:
type: list
style: vertical
label: Repeater/list with conditional field selection
fields:
.select: # this select sets the boolean for the conditional fields
type: select
size: long
classes: fancy
label: Select the type of field you would like to add
options:
tinymce: Textarea
slideshow: Slideshow
testimonial: Testimonial
video: Video
.tinymce:
type: conditional # if Textarea was selected render the tinymce fields
condition: "header.field.selection.select is same as('tinymce') ? 'true' : 'false'"
fields:
.fieldName:
type: text
label: Tinymce
.slideshow:
type: conditional # if slideshow was selected render the slideshow fields
condition: "header.field.selection.select is same as('slideshow') ? 'true' : 'false'"
fields:
.fieldName2:
type: text
label: Slideshow
.testimonial:
type: conditional # if testimonial was selected render the testimonial fields
condition: "header.field.selection.select is same as('testimonial') ? 'true' : 'false'"
fields:
.fieldName3:
type: text
label: Testimonial
.video:
type: conditional # if video was selected render the video fields
condition: "header.field.selection.select is same as('video') ? 'true' : 'false'"
fields:
.fieldName4:
type: text
label: Video
لا يعد الحقل الشرطي شيئًا يعمل "مباشرًا" استنادًا إلى الحقول الأخرى ، بل يمكنه ببساطة تنفيذ وظيفة PHP عند تقديم الخدمة واتخاذ قرار بعد ذلك. سيتطلب أي شيء آخر تشغيل جافا سكريبت.
شكرا روستر.
تمكنت من إنشاء "حقل محتوى مرن" ** (مثل الحقول المخصصة المتقدمة في Wordpress). يمكنك رؤية الرمز هنا
** حدد مجموعات الحقول الفرعية (التخطيطات) وقم بإضافتها وتحريرها وإعادة ترتيبها لإنشاء محتوى مخصص للغاية!
أحب أن أرى شيئًا مثل هذا حقلًا أساسيًا في البرنامج المساعد للنموذج :) ربما العلاقات العامة ؟؟
تضمين التغريدة
تم تقديم طلب سحب لفرع "الميزة / حقل الشكل المرن".
حالة:
أحتاج إلى بعض المساعدة في:
tnx
(أنا على قناة Slack باسم "genenenenaam")
تضمين التغريدة
هل هناك بعض التبعية على "فرز عناصر القائمة" واسم قالب الحقل "list.html.twig"؟
لقد أجريت اختبارًا ويبدو:
أعتقد أن الإجابة على هذا يمكن أن تحل مشكلتي مع الحالة الحالية للميزة الجديدة.