Freitextfeld im Frontend (Account & Profil) anzeigen

Hallo Zusammen,

ich habe im Frontend Registrierungsformular ein neues Feld (Mitgliedsnummer) hinzugefügt via Freitextfelder.
Das klappt auch alles soweit wenn ma sich registriert und eine Mitgliedsnummer einträgt kann ich die Mitgliedsnummer im Backend unter Kundenprofil sehen und beabreiten.

Jetzt möchte ich, dass die Mitgliedsnummer im Frontend unter Profil Übersicht und Persönliche Daten angezeigt wird.
Im Profilübersicht nur als Text und unter Persönliche Daten als Textfeld (wie Vorname, Nachname, etc.)

Ich habe schon einiges ausprobiert leider komme ich nicht wirklich weiter.

  1. Profil/Konto Übersicht

         {block name="frontend_account_index_welcome"}
             
                 {block name="frontend_account_index_welcome_headline"}
                     {s name='AccountHeaderWelcome'}{/s},
                         {if {config name="displayprofiletitle"}}
                             {$sUserData.additional.user.title}
                         {/if}
                         {$sUserData.additional.user.firstname|escapeHtml}
                         {$sUserData.additional.user.lastname|escapeHtml}
                     
                 {/block}
    
                 {block name="frontend_account_index_welcome_content"}
                     
                         {s name='AccountHeaderInfo'}{/s}
                         
     						{s name='AvDMitgliedsnummerInfo'}{/s} {$s_user_attributes.avdmitgliedsnummer}
     					
                     
                 {/block}
             
         {/block}
    
  2. Persönliche Daten

                                 {* Lastname *}
                                 {block name="frontend_account_profile_profile_input_lastname"}
                                     
                                         
                                     
                                 {/block}
                                 
                                 {* AvDMitgliedsnummer *}
                                 {block name="frontend_account_profile_profile_input_avdmitgliedsnummer"}
                                     {s name='ProfilePersonalAvDMitgliednummer'}{/s}
                                     
                                         
                                     
                                 {/block}
    

Alles wird angezeigt nur die Mitgliedsnummer wird nicht aus der Datenbank gezogen…

Was mach ich hier falsch?

Controllers/Frontend/Account.php ladet im “preDispatch”:

$userData = $this->admin->sGetUserData();
...
$this->View()->assign('sUserData', $userData);

und sGetUserData() ladet irgendwo die s_user_attributes wie folgt:

        $attributes = $this->attributeLoader->load('s_user_attributes', $userId);
        $userData['additional']['user'] = array_merge($attributes, $additional);

Also im Profil/Konto Überischt brauchst Du wahrscheinlich:

{block name="frontend_account_index_welcome_content"}
  
    {s name='AccountHeaderInfo'}{/s}
    
	  {s name='AvDMitgliedsnummerInfo'}{/s} {$sUserData.additional.user.avdmitgliedsnummer|escapeHtml}
	
  
{/block}

 

Perfekt! Vielen Dank.

Ich habe es jetzt auch bei Persönlcihe Daten eingefügt.
Es wird auch in einem Input Feld angezeigt. Wie kriege ich es jetzt so hin sodass der Kunde die Mitgliednummer selber ändern kann?

{* AvDMitgliedsnummer *}
{block name="frontend_account_profile_profile_input_avdmitgliedsnummer"}
  {s name='ProfilePersonalAvDMitgliednummer'}{/s}
  
    
  
{/block}

Sobald ich es änder und auf „Änderung speichern“ klicke steht dort zwar „Änderungen erfolgreich abgespeichert“ aber die Mitgleidsnummer wird wieder die alte.

Befindet sich dein Block „frontend_account_profile_profile_input_avdmitgliedsnummer“ innerhalb des Formular-Tags der Seite?

Stil: 

... ...

Sonst werden die Daten des Input-Felds nicht mitgeschickt im Post und können die also nicht abgespeichert werden.

Ja, es befindet sich innerhalb des Formular-Tags…

Hier ist der Code des Templates:

{extends file='frontend/account/index.tpl'}

{* Breadcrumb *}
{block name='frontend_index_start' append}
...
{/block}

{* Main content *}
{block name="frontend_index_content"}
    

        {block name="frontend_account_profile_profile_form"}
            

                {block name="frontend_account_profile_profile_panel"}
                    

                        {block name="frontend_account_profile_profile_title"}
                        ...{/block}

                        {block name="frontend_account_profile_profile_body"}
                            

                                {block name="frontend_account_profile_profile_success"}
                                ...
                                {/block}

                                {* Error messages *}
                                {block name="frontend_account_profile_profile_errors"}
                                ...
                                {/block}

                                {* Salutation *}
                                {block name='frontend_account_profile_profile_input_salutation'}
                                ...
                                {/block}

                                {* Title *}
                                {block name='frontend_account_profile_profile_input_title'}
                                ...
                                {/block}

                                {* Firstname *}
                                {block name='frontend_account_profile_profile_input_firstname'}
                                ...
                                {/block}

                                {* Lastname *}
                                {block name="frontend_account_profile_profile_input_lastname"}
                                ...
                                {/block}
                                
                                {* AvDMitgliedsnummer *}
                                {block name="frontend_account_profile_profile_input_avdmitgliedsnummer"}
                                    {s name='ProfilePersonalAvDMitgliednummer'}{/s}
                                    
                                        
                                    
                                {/block}

                                {* Birthday *}
                               ...
                                {/block}

                                {block name="frontend_account_profile_profile_required_info"}
                                ...
                                {/block}

                            
                        {/block}

                        {block name="frontend_account_profile_profile_actions"}
                            
                                {block name="frontend_account_profile_profile_actions_submit"}
                                    
                                        {s name="ProfileSaveButton"}{/s}
                                    
                                {/block}
                            
                        {/block}
                    
                {/block}
            
        {/block}

...

 

Info: Hab das Template und die Inhalte der Blöcke hier mit ... gekürzt damit es nicht zulang wird.

Im /engine/Shopware/Bundle/AccountBundle/Form/Account/ProfileUpdateFormType.php wird das Formular gebuildet (buildForm) mit zB.

$builder->add('firstname', TextType::class, [
            'constraints' => [new NotBlank(['message' => null])],
        ]);

und weil getBlockPrefix() ‘profile’ zurückgibt, wird folgender Input Tag geschrieben:

Ähnlich wie ‘firstname’ werden auch die Attribute mit $builder->add zugefügt unter ‘attribute’, also ich glaube Du brauchst da

 

Funktioniert perfekt.

Danke!