0

I have Yii2 application which uses the webvimark/user-management module to deal with Users. I've created additional model called UserProfile which adds some additional functionality and fields. For those interested, I followed this guide: https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration

I got pretty much everything working, having a custom registration form created to work with the new profile fields. The only problem that I have is how to replace the original form included in the module without modifying it. In here, webvimark suggests to use theming to do so: https://github.com/webvimark/user-management/issues/10

How do I theme just that one file containing the form though? I wouldn't want to change the rest and all the examples of theming I can find overwrite a whole directory. Any suggestions?

mmvsbg
  • 3,570
  • 17
  • 52
  • 73

1 Answers1

1

After a lot of head banging it turns out that the answer is quite simple. You do have to use theming for the whole directory as there is apparently no other option. However, I found this little article, which says that once you use theming and your controller tries to load a view then it will be first searched under the new theming directory that you created BUT if it's not found there, you go back to the original directory.

In other words, you overwrite the whole directory but if you provide only one view in the new one, the rest will stay the same, which is quite beautiful.

I'm posting the code that I wrote down in my web config file just in case someone struggles with paths:

'components' => [
    'view' => [
        'theme' => [
            'pathMap' => [
                '@app/vendor/webvimark/module-user-management/views/auth' => '@app/views/user-profile'
            ],
        ],
    ],
],
mmvsbg
  • 3,570
  • 17
  • 52
  • 73