Skip to content
Discussion options

You must be logged in to vote

Feel free to check this out (make sure you have newest version installed):

import { effect, track, createContext } from 'ripple';

export const FormContext = createContext<Record<string, any>>({});

function register(name: string) {
	const formData = FormContext.get();

	return {
		name: name,
    value: @formData[name],
    oninput: function (e: any) {  
      e.preventDefault();
      formData = {...@formData, [name]: e.target.value};
    },
    onchange: function (e: any) {
      e.preventDefault();
      formData = {...@formData, [name]: e.target.type === 'checkbox' ? e.target.checked : e.target.value};
    }
	};
};

export component Form({ id, children, initialValues, onChange }) {
    

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@WebEferen
Comment options

@leonidaz
Comment options

@sreekar339339
Comment options

Answer selected by onionhammer
Comment options

You must be logged in to vote
1 reply
@WebEferen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants