Я использую плагин ACF на своем веб-сайте, и мне нужна ситуация, в которой определенное поле требуется ТОЛЬКО, когда другие поля не пусты.В данном конкретном случае поле «Заголовок» не обязательно.Однако, когда одно из следующих полей не является пустым, оно должно быть обязательным: Сделка или Скидка, Описание, Обычная цена, Цена со скидкой / цена сделки и Действителен до.Мне нужна такая ситуация, потому что либо все поля должны быть пустыми, либо все поля должны быть заполнены.
Это код json, который я создал до сих пор:
[
{
"key": "group_deal1",
"title": "Deal 1 test 2 (displayed on homepage)",
"fields": [
{
"key": "field_deal1title",
"label": "Title",
"name": "deal_title_one_test1",
"type": "text",
"instructions": "(max. 100 characters)",
"required": [
[
{
"field": "field_deal1dealdiscount",
"operator": "!=empty"
}
],
[
{
"field": "field_deal1description",
"operator": "!=empty"
}
],
[
{
"field": "field_deal1regularprice",
"operator": "!=empty"
}
],
[
{
"field": "field_deal1discountedprice",
"operator": "!=empty"
}
],
[
{
"field": "field_deal1validdate",
"operator": "!=empty"
}
]
],
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "deals-title",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": 100
},
{
"key": "field_deal1dealdiscount",
"label": "Deal or Discount",
"name": "discount_deal_or_special_one",
"type": "radio",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"Discount": "Discount",
"Deal": "Deal"
},
"allow_null": 1,
"other_choice": 0,
"default_value": "",
"layout": "vertical",
"return_format": "value",
"save_other_choice": 0
},
{
"key": "field_deal1description",
"label": "Description",
"name": "deal_description_one",
"type": "textarea",
"instructions": "(max. 600 characters)",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "deals-description",
"id": ""
},
"default_value": "",
"placeholder": "",
"maxlength": 600,
"rows": "",
"new_lines": ""
},
{
"key": "field_deal1regularprice",
"label": "Regular price",
"name": "regular_price_one",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "deals-regular-price",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "$",
"append": "",
"min": "",
"max": "",
"step": ""
},
{
"key": "field_deal1discountedprice",
"label": "Discounted price \/ deal price",
"name": "discounted_price_one",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "deals-discounted-price",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "$",
"append": "",
"min": "",
"max": "",
"step": ""
},
{
"key": "field_deal1validdate",
"label": "Valid until",
"name": "valid_until_one",
"type": "date_picker",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"display_format": "m\/d\/Y",
"return_format": "m\/d\/Y",
"first_day": 1
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "post"
},
{
"param": "post_format",
"operator": "==",
"value": "aside"
}
],
[
{
"param": "post_format",
"operator": "==",
"value": "status"
}
]
],
"menu_order": 1,
"position": "acf_after_title",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": ""
}
]
Это не работает.. Это дает мне результат, в котором поле Заголовок требуется всегда.
Надеюсь, кто-то может помочь.Заранее спасибо!
PS.Я знаю, как скрыть поля с условной логикой, но это не очищает поля и поэтому все еще будет видно на веб-сайте.Поэтому другим решением будет очистить поля, когда заголовок пуст.