Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DynamicForm with binary field: add/update RPC associated with child form instead of main form

    SmartClient Version: v13.1p_2026-02-03/AllModules Development Only (built 2026-02-03)

    Hi, I’m noticing some behavior that doesn’t seem completely correct when using a DynamicForm with a binary field.

    I modified the “upload” showcase example as follows:

    Code:
    <DataSource ID="mediaLibrary" serverType="sql" tableName="mediaLibrary">
        <fields>
            <field name="pk" type="sequence" hidden="true" primaryKey="true"/>
            <field name="title"/>
            <field name="image" type="binary" maxFileSize="5242880" />
        </fields>
    </DataSource>
    Code:
    isc.DynamicForm.create({
        autoDraw: false,
        ID: "uploadForm",
        width: 300,
        dataSource: mediaLibrary,
        fields: [
            { name: "title", required: true },
            { name: "image", title: "File", multiple:false, hint: "Maximum file size is 5 MiB", canEdit: true },
            { title: "Save", type: "button",
                click: function (form, item) {
                    form.saveData("if(dsResponse.status>=0) uploadForm.editNewRecord()");
                }
            }
        ]
    });
    
    
    isc.ListGrid.create({
        autoDraw: false,
        ID: "mediaListGrid",
        width: 500,
        height: 224,
        dataSource: mediaLibrary,
        autoFetchData: true,
        recordClick:"uploadForm.editRecord(record)"
    });
    
    isc.HStack.create({
        width:"100%",
        membersMargin: 10,
        members:[uploadForm, mediaListGrid]
    });
    Whether I save a new record (with or without a file), or click a record in the grid and then modify the title or select a different file, when I click “Save” I see the related add/update requests in the RPC tab of the Developer Console associated with componentId isc_DynamicForm_0, which is the child of uploadForm.

    If instead the FileItem is read-only (in this case I obviously have to remove maxFileSize from the DataSource), then I see the add/update requests associated with uploadForm itself.

    Aside from the confusion this causes when inspecting the Developer Console, I’m wondering whether this could be a bug and whether it might lead to any unexpected or incorrect behavior.


    #2
    Not a bug. The upload input is treated specially because we can't freely redraw it (or we would lose the file the user picked). So we put it in a separate native form that never redraws.

    However the means that separate form has to be the one that does the submit when the file is being changed, because we can't just move the picked file around freely to other forms.

    In more recent browsers, we could avoid this for some cases, but not all - there are still obscure CORS situations and embedded browsers and stuff like that where the structure we're using is necessary.

    Comment

    Working...
    X