Embed Express Form block inside Express Entry List Block, plus modify form field and insert data

You can structure it however you want that makes most sense for you.

You can keep code for every form in different package or keep them in one (you could consider changing namespace/package name to something more general).

You can change it to something like (when you move existing code to src/tournament_registration folder):

protected $pkgAutoloaderRegistries = [
    'src/tournament_registration' => 'TournamentRegistrationForm',
    'src/folder_two' => 'OtherNamespace',
];

and it will be used as:

namespace OtherNamespace;

and so on.

You can also change package name/namespaces in files (though it will require basic understaning of namespaces in PHP):

protected $pkgAutoloaderRegistries = [
    'src' => 'FormModifications',
];

and keep all files in src like now. You can add next controllers/overrides etc., just stick to sensible naming convention, so you won’t be lost later.

1 Like

I’m not entirely following you on your explanation of this part. I’m not sure how from a structured perspective this would translate into how I use this (as in, being called in PHP), and the logical folder structure this would then lead to requiring. I do see this results in /src/somethingOrOther, but the somethingOrOther and execution/usage of such isn’t yet visible to me.

I do for sure want to use good habits, sensible naming conventions, stuff like that, so I appreciate your advice on this. :^)

And yes, in this particular case the package has a whole bunch of different things, and one of them is the Tournament Registration Form, plus already like 7 templates, and more to be expected. hehe.

As an aside, I’ve been able to get my second form working with your provided code, yay! Just need to style it now, hehe. Thanks again for all your help!

You can have multiple files like:

TournamentRegistrationForm\Express\Controller\TournamentRegistrationFormController
TournamentRegistrationForm\Express\Controller\OtherFormController
TournamentRegistrationForm\Express\Controller\ThirdFormController

and bind each one to different form in on_start(). Each controller will do its own stuff.
In this case TournamentRegistrationForm namespace doesn’t make much sense, better to use it as something like:

FormModifications\Express\Controller\TournamentRegistrationFormController
FormModifications\Express\Controller\OtherFormController
FormModifications\Express\Controller\ThirdFormController

Though you can leave it as TournamentRegistrationForm if it doesn’t bother you.

Are you describing how PHP invokes each controller? Or how they are stored “on-disk” so to say?

Here’s the impression I get from your most recent explanation:

In /controller.php:

protected $pkgAutoloaderRegistries = [
    'src' => 'FormModifications',
];

And then, “on-disk” we have:

/src/FormModifications/Express/Controller/TournamentRegistrationFormController.php
/src/FormModifications/Express/Controller/OtherFormController.php
/src/FormModifications/Express/Controller/ThirdFormController.php

And then when I want to invoke (not even sure I’m using the right term there) I would use…

FormModifications\Express\Controller\TournamentRegistrationFormController
FormModifications\Express\Controller\OtherFormController
FormModifications\Express\Controller\ThirdFormController

How close to “correct” am I here? :thinking:

For

protected $pkgAutoloaderRegistries = [
    'src' => 'FormModifications',
];

it is like

/src/Express/Controller/TournamentRegistrationFormController.php

and then in files it is used as:

namespace FormModifications\Express\Controller;
class TournamentRegistrationFormController 
{
}

etc.
Left part of pkgAutoloaderRegistries is location on disk, right part is how it is translated.

1 Like