I created a few new fields in the Magento 2 customer signup. I used a uicomponent, and inserted it into the register.phtml form using <!-- ko template: getTemplate() -->
It shows up fine, but now, I don't know how to get the values into the db.
I created the attributes in the database using install/upgradeData script, but how to I actually get the data from the form into the db?
Example input:
<label for="input-for-other" class="label">Other</label>
<div class="control">
<input type="text" name="input_for_other" id="input-for-other" title="Other" class="input-text">
</div>
JS file
```
define(['jquery', 'uiComponent'], function ($, Component) {
'use strict'
return Component.extend({
defaults: {
...
otherKind: '',
...
},
initObservable: function () {
this._super().observe([..., 'otherKind', ...]);
return this;
}, })});
We're in the R&D stage and looking at the best way to allow users of our system to manually add fields to an entity. The usual way of doing this is via some kind of EAV set up, but I've found nothing but bad things said about building projects like this, however, no one seems to offer an alternative to EAVs when the user needs the ability to add an number of extra fields to a model.
Initially we were thinking of doing this using a JSONB column within PostgreSQL instead of a number of different tables to avoid needing extra JOINS when getting its data, however, this lead down the path of "why not just put everything in the JSONB column" because we can still query on fields within the JSON. The final table would basically have 3 columns, ID, Entity and JSON.