By adding an input file in EditUserModal to input data into the birthdate field in the user table in the database,I can see the entered birthday data in the database, and the data I entered in login status can also be displayed on the user profile page. However, when I log out and log in again, the birthday data cannot be displayed on the user profile page
What do I need to do to show the value?
index.js
import { extend } from "flarum/extend";
import UserCard from "flarum/components/UserCard";
import Model from "flarum/Model";
import User from "flarum/models/User";
import Stream from "flarum/utils/Stream";
import EditUserModal from "flarum/components/EditUserModal";
app.initializers.add('mysite/test', () => {
User.prototype.birthday= Model.attribute("birthday");
extend(EditUserModal.prototype, "oninit", function () {
this.birthday= Stream(this.attrs.user.birthday());
});
extend(EditUserModal.prototype, "fields", function (items) {
items.add(
"birthday",
<div className="Form-group">
<label>
birthday
</label>
<input
className="FormControl"
bidi={this.birthday}
/>
</div>,
1
);
});
extend(EditUserModal.prototype, "data", function (data) {
if (this.birthday() !== user.birthday()) {
data.birthday= this.birthday();
}
});
// show nothing here
extend(UserCard.prototype, "infoItems", function (items) {
items.add("birthday", <p>{this.attrs.user.birthday()}</p>);
console.log(this.attrs.user.birthday())
});
});
console.log(this.attrs.user.birthday())
the result
index.js:23 ƒ (t,e){return function(){return e?e(this.attribute(t)):this.attribute(t)}}