Home › Forum › Problemi Vari con WP › Aggiungere custom field dinamicamente tramite jquery
-
AutorePost
-
-
23 Giugno 2011 alle 13:01 #18296mic3000Partecipante
Ciao a tutti ho creato il mio custom metabox dove all’interno tramite jquery cliccando su “add student” vado ad aggiungere i miei 3 custom field nome cognome e telefono.
Tramite jquery append duplico ad ogni click l’intera tr contenente i tre custom fields.
Come faccio a salvare questi valori?
Come faccio a visualizzare questi valori nel metabox una volta salvati? Mi spiego meglio, ad esempio se io ho aggiunto 2 righe e quindi 6 custom field, quando andrò ad editare il mio articolo nel mio metabox dovrò vedere le tr già inserite ed eventualmente poterle aggiungere o rimuovere.
Allego uno screenshot che magari può aiutare a chiarire meglio!
Se qualcuno conoscesse un tutorial o una guida…
Grazie!
-
23 Giugno 2011 alle 13:06 #85835SteveAglAmministratore del forum
Non fai cosଅ non devi dulicarla.. di certo lapproccio NON è corretto ma NON ho capito per nulal quello che dovresti fare esattamente… noi nons iamo nella tua testa ricordalo.
-
23 Giugno 2011 alle 14:07 #85839mic3000Partecipante
Lo so che non siete nella mia testa, per questo ho fatto anche lo screenshot!
Comunque ho creato un custom metabox e all’interno di questo a seconda dell’articolo che sto scrivendo, ho la necessità di aggiungere piu studenti (nome, cognome, telefono).
Non sapendo a priori quanti studenti dovrò inserire, pensavo di aggiungerli tramite jquery!
Qual’è l’approccio corretto?
Grazie
-
23 Giugno 2011 alle 15:05 #85845SteveAglAmministratore del forum
Usa lo stesso sistem usato dal custom post type che non ho idea quale sia ma è in jquery pure lui… ma non aggiunge metabo ma i campi…
-
23 Giugno 2011 alle 19:34 #85853AndreamkPartecipante
Nei campi di input metti come name una stringa con parentesi quadre.
es
<input type=”text” name=”cognome[]” value=”” >
Cosi facendo $_GET reastituisce un array di valori che potrai salvare.
In fase di creazione del metabox leggendo le opzioni se hai più lavori puoi crearlo con più linee già valorizzate.
Ciao
Andrea
p.s. Per me l’approccio non ha nulla di sbagliato semplicemente devi gestire array al posto di valori singoli.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.