Replies: 1 comment
-
There's no "official" or "Felte" way to do this. Computed values are something frameworks are generally good at. If you're using Svelte, for example: <script>
const { form, data } = createForm({ /* ... */ });
$: computed = $data.value /* Do something here with $data.value */;
</script>
<form use:form>
<!-- .... -->
<input disabled value={computed}>
</form> Svelte is specially good at this since the If you're using Solid/React/Preact then the "signal" call can be used to compute a value. E.g. for Solid: function Form() {
const { data, form} = createForm({ /* ... */ });
const computed = () => data(($data) => $data.value /* Do something with the value */)
return (
<form use:form>
{/* ... */}
<input disabled value={computed()} />
</form>
)
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to have computed fields for my form. E.g. I implement an invoice form with an items array (quantity, price for one). Then I have to compute certain fields on the items array and summing for the whole invoice, tax etc.
The computed fields should also be input fields (but disabled)
An approach I could imagine would be to subscribe to the data store and update certain fields...
But is this a "good" way. Is there a "felte" way to do this?
TIA
Beta Was this translation helpful? Give feedback.
All reactions