Must click "Update" twice to save values to post_meta
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, php
Direzione di ricerca
Inizia riproducendo il flusso di aggiornamento del blocco con acf.getField(), field.val() e field.$input().trigger('change') nell’esempio dell’issue. Esamina come l’API JavaScript ACF gestisce le cambiamenti di valore e conferma che il primo Update persiste il valore in post_meta senza una modifica manuale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 947
- Fork
- 198
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AdvancedCustomFields/acf
-
PHP 8.5: "Using null as an array offset" deprecation in ACF_Data::is() when rendering a block with empty data (local-meta.php is_request)Forse già presa @faisalahammad l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AdvancedCustomFields/acf#1044 ·
-
is_preview was called incorrectly notice on every early get_field() since 6.8.10 (acf_revisions::acf_validate_post_id)Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
AdvancedCustomFields/acf#1041 · 1 commento ·
-
True / False ACF control bug on RTL layoutsForse già presa @elicohenator l’ha presa 24 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
AdvancedCustomFields/acf#1038 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
AdvancedCustomFields/acf#1034 · 3 commenti ·
-
Bug: class-acf-field-icon_picker.php calls wp_get_attachment_image_url() with string Dashicon slug, causing fatal TypeError on PHP 8+Forse già presa @antwonw l’ha presa 35 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
AdvancedCustomFields/acf#1032 · 1 commento ·
Tutte le issue di AdvancedCustomFields/acf
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ProfessionalWiki/NeoWiki#1675 ·
I maintainer di solito rispondono entro 1 giorno
-
Incorrect documentationAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
WhatsApp link preview crawler is not detected as a botForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
matomo-org/device-detector#8405 ·
I maintainer di solito rispondono entro 1 giorno