Skip to content

data-bw-action should support collecting multiple form fields #78

@deftio

Description

@deftio

Problem

When a data-bw-action button fires, bwclient.js resolves one inputValue from the nearest text input in the same parent div. For single-input forms (chat, search), this works perfectly.

For multi-field forms (e.g., name + genre dropdown + persona textarea + model + temperature), you're forced into a workaround:

client.exec(`
  (function() {
    var name = document.getElementById('form-name').value;
    var genre = document.getElementById('form-genre').value;
    var persona = document.getElementById('form-persona').value;
    var model = document.getElementById('form-model').value;
    var temp = document.getElementById('form-temp').value;
    bw._bwClient.sendAction('do-submit', { name, genre, persona, model, temperature: temp });
  })();
`);

This bypasses the declarative data-bw-action pattern entirely and requires knowing element IDs, writing escaped JS strings, and manually wiring submit.

Proposed Fix

Option A: Resolve all named inputs in the container:

// Current: finds first text input, returns { inputValue: "..." }
// Proposed: finds all inputs with name/id, returns { inputValue: "first", fields: { name: "...", genre: "...", ... } }

Option B: Add data-bw-collect attribute that serializes a form:

<form data-bw-collect>
  <input name="title" ...>
  <select name="genre" ...>
  <textarea name="persona" ...>
  <button data-bw-action="submit-form">Save</button>
</form>

When the button fires, payload includes all named fields from the data-bw-collect container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions