[Bug 24603] New: [Custom]: Need callback for form submit data

https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603

            Bug ID: 24603
           Summary: [Custom]: Need callback for form submit data
           Product: WebAppsWG
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Component Model
          Assignee: dglazkov@chromium.org
          Reporter: arv@chromium.org
        QA Contact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, public-webapps@w3.org
            Blocks: 14968

<form>
  <my-custom-input name="abc"></my-custom-input>
</form>

Right now there is no way to have custom elements include data in form
submissions. We should add another callback for this

I believe we need to add a callback that is called before the submit event.

Strawman:

document.registerElement('input', {
  prototype: {
    __proto__: HTMLElement.prototype,
    beforeSubmitCallback: function() {
      switch (this.type) {
        case 'checkbox';
          if (this.checked)
            return this.value;
          return undefined;
        ...
      }      
    }
 }
});

Basically, the contract is that the return value of the callback is used a the
form value. If undefined is returned nothing is serialized.

This is of course a bit too simplistic but it might be enough to get started.

Things to keep in mind:

- Radio buttons need to check outside itself
- input[type=file]. Return Blob|File|data url?
- input[multiple]. Array of values?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Monday, 10 February 2014 16:09:18 UTC