joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Add a render method for generating forms

Open rglover opened this issue 1 year ago • 0 comments

Not 100% sure of the API for this yet, but something like this would be helpful:

form('signup', {
  classes: {
    labels: 'mod-label',
    inputs: 'mod-input',
  },
  rows: [{
    fields: [
      { label: 'Email Address', type: 'email', name: 'email_address', placeholder: 'Email Address', value: '', columns: 6 },
      { label: 'Password', type: 'password', name: 'password', placeholder: 'Password', value: '', columns: 6, hint: 'Use at least eight characters, one uppercase letter, one lowercase letter, and a special character.' },
    ]
  }]
})

This would also allow for tracking form instances on the component instance at something like instance.forms.signup which would point to the DOM node for that form for convenience. It may be out of scope, but you could even add a validation schema directly to this that would automate calling to the instance.validate_form() method.

rglover avatar Jan 31 '24 04:01 rglover