Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Trying to unravel the mystery of field binding

Đang mở
#144 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
25/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, node.js
Lĩnh vực
backend, documentation

Hướng nghiên cứu

Bắt đầu với tài liệu về binding và ví dụ xây dựng trường động trong issue, tập trung vào cách cung cấp giá trị ban đầu cho một đầu vào được tạo. Làm rõ điểm truy cập được hỗ trợ và cho biết kết quả hiển thị thành công sẽ hiển thị gì, đồng thời đề cập đến việc bind có được thiết kế cho mục đích này hay không.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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' });
Ngôn ngữ chính
JavaScript
Star
1k
Fork
160
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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của caolan/forms

Tất cả issue của caolan/forms

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.