Must click "Update" twice to save values to post_meta
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, php
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện quy trình cập nhật block với acf.getField(), field.val() và field.$input().trigger('change') trong ví dụ của issue. Kiểm tra cách ACF JavaScript API xử lý các thay đổi giá trị và xác nhận rằng lần Update đầu tiên sẽ lưu giá trị vào post_meta mà không cần chỉnh sửa thủ công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
UPDATE 2:
Properly triggering a change event on the input also solves the issue. DO NOT trigger an event on a jQuery selector of the input (like I tried a million ways).
let field = acf.getField('field_123456');
// trigger change event on $input()
field.$input().trigger('change');
UPDATE:
Works fine if I set a value attribute on the input element. Plain javascript because jQuery's prop() and attr() didn't seem to work.
let field = acf.getField('field_123456');
field.val('some value');
// add value attribute to input
document.querySelector('.acf-field[data-key="field_123456"] .acf-input-wrap input').setAttribute('value', 'some_value');
I'd still love to understand the original issue. Maybe some sort of "dirty" status that's not set when using ACF val() but is set when editing the field manually?
Describe the bug
Wondering if anyone has any insight on a custom ACF block issue? ("blockVersion": 3, "usePostMeta": "true"): values set in block with javascript are not saved to Db unless Update is clicked twice.
Within wp-admin, editing a post:
- I set a field value via javascript while a block is being edited:
let field = acf.getField('field_123456');
field.val('some value');
- I see the value in the text input on-screen
- I click "Update" for the post, but value is not written to dB. ***
- I click "Update" a second time, and value IS written to the database.
*** If I manually place the cursor in any field in the block and add/delete a character, THEN values are saved the first time I click "Update"
Sure seems like ACF triggers some event/condition when there's a manual edit, but NOT when the value is changed via the ACF JS API.
What is that event/condition? I've had no luck figuring it out...
To Reproduce
See above
Expected behavior
When I click Update the first time to save the post, the values set via the ACF JS API are saved to the db.
Version Information:
- WordPress Version [6.9.1]
- PHP Version [e.g 8.5]
- ACF Version [e.g ACF PRO 6.7.0.2]
- Browser [all of them...]
Additional context
I've submitted a ticket, and searched the forum but did not find this issue.
- Ngôn ngữ chính
- PHP
- Star
- 946
- Fork
- 197
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AdvancedCustomFields/acf
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1041 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1038 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1034 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1032 · 1 bình luận ·
-
Drop trap, acf_after_titleĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1029 · 1 bình luận ·
Tất cả issue của AdvancedCustomFields/acf
Issue tương tự
-
Infrastructure: actions Module: zmscitizenapi Module: zmsentities php Type: Bug unit tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
it-at-m/eappointment#3480 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CI: composer install fails — league/flysystem 1.x blocked by security advisory GHSA-cxf4-7mrp-vvprĐang mởdevops type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs approval
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 3 ngày
-
product / avatars product / self-hosted product / storage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
appwrite/appwrite#13985 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày