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

Yeah renaming the folder for the template to “tournament_registration_form” does not appear to have changed the results. I am going to rename it back to “event_page_tournaments_register”.

Hoping to hear from you soon :slight_smile:

As always, thanks!

I am trying all sorts of different things here.

I’ve tried changing the target property from “event_tournaments” to “event_tournament”. No change in result.

I’ve tried deleting and re-creating the association of ManyToOne from the Reg List Object to Event Tournaments, and in creating that having it use “event_tournament” from the start. No change in result.

I’ve tried “HTML Input” and “Entry Selector” for the “Input Format” on the Form used as defined in the Dashboard for the Express Object. No change in result in either method.

Not yet seeing what I should do here. :s

Oh and as of right now the template for the Form, the folder for it, is named “tournament_registration_form” since I really suspect the other code you’ve written likely connects to this exact name for the template (speculation, based on what I’ve been reading in the code).

I am not sure if this is somehow relevant, but as a heads-up, the “Event Tournaments” Express Object uses the current Name Mask of “%games% %event_tournaments_rule_sets%”.

I am not sure if that is getting in the way of this method…

Adding the override of “%id%” to “Association Entity Display Format” for the Association field in the Form I’m using, and having the “Input Format” set to HTML Input, shows the ID # of the Tournament options. However this still does not change the results, in that the pop-up does not pre-select the Tournament for the user.

Hmmmm…

If everything is working (beside js), just add alert('test') or console.log() inside $('xxxx').on('click', function (e) {}, to see if it is actually triggering.

Does data-express-field-handle="event_tournaments" attribute actually exist in html source? Check page source (CTRL-U) or in inspector (F12).

1 Like
  1. adding alert('test') results in the expected basic “test” pop-up text window, so that looks to be executing
  2. reading the source code of the page I see the JS script block, which does have data-express-field-handle="event_tournaments"

And after clicking the “test” pop-up, the form comes up, but does not appear filled in (it is currently configured with pull-down select menu, HTML not entry select).

Where should I check next? Also, the form, should I be using Entry select method or HTML input method?

Any idea? :confused: I’m still stuck here.

Next thing I tried… no positive result change just yet…

I noticed that /elements/express/form/tournament_registration_form/association/select.php was based on v9.1.x (based on the Concrete CMS content for this file unmodified)

However I am on v8.5.x, and I noticed a pretty big difference between the original versions (from Concrete CMS repo, v8.5.x vs v9.1.x)

I compared the version you wrote to the original v9.1.x and noticed only a delta on the line with “<select class…”.

However, on that equivalent line in v8.5.x, the class uses a different term.

So I took the v8.5.x original version ( concretecms/select.php at 8.5.x · concretecms/concretecms · GitHub ) and added the part you wrote…

data-express-field-handle="<?= h($targetHandle); ?>"

Within the HTML block

However this does not appear to change the results, as the value still does not seem to get inserted. But at this time I’m still going to stick with this version as the v9.1.x class value is “form-select” and v8.5.x is “form-control”.

I keep on the hunt, and am hoping this gets figured out soon, going a bit insane here @_@

One of my biggest hunches here is that the method written in your repo is for v9.1.1, as the README.md mentions, and something… somewhere… is not quite connecting due to me running v8.5.x.

Going mad trying to figure out what’s going wrong here…

Okay now this may be important, when I trigger the pop-up to render the form, I check the source code again for data-express-field-handle="event_tournaments" and it … doesn’t seem to be set for the form, and on the page source only exist in the javascript… I’m going to look into this aspect deeper.

Yeah so when I edit the HTML when inspecting (F12) and add data-express-field-handle="event_tournaments" to the <select> HTML block manually, then trigger the pop-up hyperlink, the form gets filled in.

So for a reason I don’t yet see, the form isn’t having data-express-field-handle="event_tournaments" added to that <select> HTML block…

I now have a “positive” pseudo-test sample, yay! But I need to figure out why the select.php customisation isn’t applying… hmmm…

In:

/src/Express/Form/Context/TournamentRegistrationFormContext.php

and

/src/Attribute/Context/TournamentRegistrationFormContext.php

I noticed you commented two lines in each with value ‘tournament_registration_form’ and the comment says “// This is package handle”

In my case the package handle is something else, so I updated it to the package handle defined in /controller.php

However this does not appear to result in applying the select.php customisation to add data-express-field-handle="event_tournaments"

So while I suspect I may have still needed to do this, I am on the hunt further…

I noticed that in the file:

/src/Express/Form/Context/TournamentRegistrationFormContext.php

file, the two lines I previously mentioned modifying mention they are made-up folder names, switched that from tournament_registration_form to the folder of the package (named something else), for both declarations in that file.

So far this does not appear to change the result, select.php still seems to not be applied… :s

The package I have contains a bunch of stuff that is not related to tournament stuff, as well as the tournament stuff. One big package, and my preference is to keep it that way at this time.

I dig deeper…

I just noticed that you mentioned to use PHP 7.4, and this test environment is PHP 7.2

I’m going to take a backup of this environment, and switch to PHP 7.4, and see how that goes…

Upgrading to PHP 7.4 did not improve the situation :confused:

I made some attempts to adjust the namespace use and declaration from “TournamentRegistrationForm” to my own package name, but now I’m getting PHP errors. Either I did it wrong, or I actually shouldn’t change that. So I’m going to revert that change.

Okay so I know I kinda shot myself in the foot a bit, but… I got it working

in

/elements/express/form/tournament_registration_form/association/select.php

in the HTML block, I changed it to explicitly declare data-express-field-handle="event_tournaments" instead of injecting the variable, and it worked.

Now, I’m pretty sure the variable broke when I changed this file to be based on the v8.5.x original code from Concrete CMS’ github repo, as that removed how the variable was being created.

Anyways, it looks to be working now, at least well enough. I thank you @Parasek as this work of your still got me really going here! Yay!

Now, to clean up the code… why do I need these?:

/attributes/text/tournament_registration_form.php
/elements/express/form/view/tournament_registration_form/text.php

They look irrelevant as the text attribute type… is not what I’m working with. So I don’t see how those fit into this picture. I’d like to remove them if possible, but I also want to understand.

These are only an example how to override other parts of code. You can delete them if not needed.

In your case, you can use data-express-field-handle="event_tournaments", only problem would occur if you used 2 different express selector in form (what you are not doing).

2 Likes

I’ll have to keep that in mind, as at some point (for other purposes) I may need to handle multiple express selectors in a form in the same vein.

Thanks for your help! And I hear you on them being examples, that too is appreciated. :slight_smile: I just wasn’t sure if they somehow fit into the picture in a way that I wasn’t seeing.

1 Like

So I’m taking this method and purposing it for another form. In this case, it has multiple association selects, but only one I want to pre-populate for the user. But my question is not so much about that.

In /controller.php

In the $pkgAutoloaderRegistries declaration…

The example presented defines…

‘src’ => ‘TournamentRegistrationForm’,

Now, I’m a little uncertain on the expected behaviour in a few scenarios for adding another set of files for another form in this particular part… I have a feeling adding this would not work:

‘src’ => ‘SomethingElseForm’,

As that would duplicate what src refers to. And as of this writing the src/… contents have been duplicated and adapted to the new form. So I have a hunch I may need to make a src2 folder, or equivalent, and use:

‘src2’ => ‘SomethingElseForm’,

And move the files into that structure.

However, I am not sure if there’s a “better” way to do this, as the Concrete CMS documentation doesn’t speak to options around multiple $pkgAutoloaderRegistries being declared.

So, for the sake of the reader, the probably bad configuration could look like:

protected $pkgAutoloaderRegistries = [
‘src’ => ‘TournamentRegistrationForm’,
‘src’ => ‘SomethingElseForm’,
];

In /controller.php

But again I expect this to break.

So… what would you recommend as a good practice/habit to get into for this?

Thanks again!