Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Trying to unravel the mystery of field binding

Aperta
#144 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, node.js

Direzione di ricerca

Inizia dalla documentazione del binding e dall’esempio di costruzione dinamica dei campi nell’issue, concentrandoti su come viene fornito un valore iniziale a un campo di input generato. Chiarisci il punto di ingresso supportato e mostra cosa dovrebbe visualizzare un rendering riuscito, affrontando anche la questione se bind sia destinato a questo uso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Needs More Info

I'm dynamically creating a form based on info loaded from a json file. I've tried everything I can think of to get a value loaded from the json to display in a widget but nothing I've tried works.
The documentation regarding binding is (in my opinion) a bit opaque.
(forgive me if binding is not the right functionality - it just seemed to be what I was looking for)

This is the last obstacle I have to overcome before using forms in production.
Could someone show me the error of my ways? Thanks in advance.

To summarize: As I build the form, I have a value that I want to insert into the form input element that will be visible when the page is rendered.

/* configObject is an object parsed from json I load from a file

each itemElement below contains:
 {
    "value": <a string>,
    "type": <a string - 'integer', 'float', 'string', or 'boolean'>,
    "length": <an integer>
 }

 i.e.
    fieldName1: {
        "value": "contentOfFieldName1",
        "type": "string",
        "length": 12
    }  

*/

_.each(configObject, function (itemElement, itemIndex) {
    if (['integer', 'float'].indexOf(itemElement['type']) >=0) {
        fieldType = 'number'
    } else {
        fieldType = itemElement['type'];
    }
    /* 
       At this point, itemElement.value = the value I want to insert as the visible value of the form field.
       How do I do this?
       I've tried newField.bind(itemElement.value);
    */
    var newField = fields[fieldType]({required: true});

    //newField.bind(itemElement.value);  // no error but nothing happens

    formObject[itemIndex] = newField;

    //formObject[itemIndex].bind(itemElement.value);  // no error but nothing happens
    //formObject.bind({itemIndex: itemElement.value}); // error: formObject has no method 'bind' });
Lingua principale
JavaScript
Stelle
1k
Fork
160
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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di caolan/forms

Tutte le issue di caolan/forms

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.