joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Add a formDefaults field to component options

Open rglover opened this issue 3 years ago • 2 comments

Have a way to autopopulate a form based on name fields using a defaults object on the component.

rglover avatar Feb 17 '22 00:02 rglover

Forgot about this. Would be really helpful for testing in development.

rglover avatar Jul 11 '22 20:07 rglover

Shouldn't be too hard to do. Just provide a map like this:

import joystick from '@joystick.js/ui';

joystick.component({
  // NOTE: Showing a function example because this could be helpful beyond development (e.g., a profile page).
  formDefaults: () => {} 
  formDefaults: {
    firstName: 'Doug',
    lastName: 'Funnie',
  },
  render: () => {
    return `
      <input type="text" name="firstName" />
      <input type="text" name="lastName" />
    `;
  },
});

rglover avatar Jul 18 '23 02:07 rglover