Override custom field

create-account.hbs

{{#if userFields}}

            <div class='user-fields'>

              {{#each userFields as |f|}}

                {{user-field field=f.field value=f.value}}

              {{/each}}

            </div>

          {{/if}}

js

var siteSettings = Discourse.SiteSettings;
    console.log(siteSettings.forum_name);

complete = $(".user-field-" + siteSettings.forum_name);

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/controllers/create-account.js.es6#L239-L245

How to check the field?

{{#if f.field.name == complete }}  {{! doesn't work }}
  OK
{{/if}}

set input for create-account.hbs

 var siteSettings = Discourse.SiteSettings;
          $('.control-label').each( function () {
  if($(this).text().trim() === siteSettings.forum_name) {
  const uuid ='lp'+(()=>([1e7]+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15 >> c/4).toString(16)))();
var id = "user-" + $(this).parent().attr('id');
    var input = $('#' + id);
    input.val(uuid);
   // $(this).parent().hide()
  
    }
})

It looks like this

Rails.logger.warn(“#{params }”)
It looks like this

"user_fields"=><ActionController::Parameters {"1"=>"true", "2"=>""}

“2”=>“”
where is the second field ?

Template에서는 실제 로직 계산을 수행할 수 없기 때문에 이 방법은 작동하지 않습니다. 이는 해당 JS 파일에서 Computed Property를 사용하여 처리해야 합니다. 공식 Ember 가이드(사용 중인 Discourse 버전과 동일한 버전을 선택하는 것)를 읽고, 이곳에서 인기 있는 Customization > Plugin 중 하나를 참고하여 예시를 확인해 보세요.

thanks for the answer, I’m interested in examples from plugins

Here’s an example of a Computed Property from a PR I recently submitted to Ebsy’s excellent National Flags plugin: discourse-nationalflags/assets/javascripts/discourse/components/user-nationalflags-preferences.js.es6 at master · Ebsy/discourse-nationalflags · GitHub

Here’s one (“showTimezones”) that is actually used to hide/show in a template: https://github.com/paviliondev/discourse-team-timezones/blob/master/assets/javascripts/discourse/components/team-display.js.es6

but you’ll find tonnes of great patterns in our plugins: Pavilion · GitHub

Hi, I figured out how to override the action in the controllers.

example

import CreateAccount from 'discourse/controllers/create-account';
export default {

    name: 'Create-Account-Popup',
    initialize: function () {
        CreateAccount.reopen({
            actions: {
                createAccount() {
// my code
                }
            }
        });
}

How to add your @discourseComputed ?

I do as in the example and does not work

export default {
    name: 'Create-Account-Popup',
    
    @discourseComputed()
    ldapForgotPassword() {
        console.log('forgot!!');
        return this.siteSettings.forum_login_popup_use_ldap;
    },

Happened through @computed

        PreferencesAccount.reopen({
            @computed
            ldapForgotPassword() {
                console.log('forgot!!');
                return this.siteSettings.forum_login_popup_use_ldap;
            },

You should use this to avoid a browser warning.

It’s just a different import:

import discourseComputed from "discourse-common/utils/decorators";