Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sub-issue for meta issue #1880976: [meta] Port examples (including submodules) to D9.4+
Problem/Motivation
D8 all the things!
Ajax Add more example is already added in fapi_example module : #2720361: Port ajax example add more and remove example from drupal 7 to drupal 8
Proposed resolution
Start with D7 version and figure out how to port ;)
Comment | File | Size | Author |
---|---|---|---|
#50 | interdiff.txt | 34.59 KB | Mile23 |
#50 | 2102639_50.patch | 57.88 KB | Mile23 |
| |||
#49 | interdiff.txt | 14.12 KB | Mile23 |
#49 | 2102639_49.patch | 62.62 KB | Mile23 |
| |||
#48 | interdiff.txt | 5.75 KB | Mile23 |
Comments
Comment #1
kerasai CreditAttribution: kerasai commentedStarted work on a port. Attached patch provides the framework of the module, and the first (of many) examples.
I'll try to attack the rest as time allows, others feel free to jump in.
Comment #2
kerasai CreditAttribution: kerasai commentedWhoopsie, made patch backwards. New patch attached.
Comment #3
Mile23Comment #4
kalinchernev CreditAttribution: kalinchernev commentedPutting this one on my list for a review during this week
Comment #5
kalinchernev CreditAttribution: kalinchernev commentedComment #6
kerasai CreditAttribution: kerasai commentedThere is most certainly work to be done on this one. I believe @Mile23 set it to "needs review" to fire off the testbot.
Comment #7
Mile23No, I set it to 'needs review' because it needs a review. :-) Part of that is the testbot.
If you'd like to make a list of things that need to be done, that would be great, and would count as a review.
Comment #8
kalinchernev CreditAttribution: kalinchernev commentedHi, thanks for quick reply.
My plan is to check the example provided by kerasai as methods, etc.
I want to spend more time into that in order to see the rest of the examples as well and help with what I can for the rest as well, so basically this is why I assigned the ticket to spend more time and go into details.
Comment #9
kalinchernev CreditAttribution: kalinchernev commentedHi back, the patch is ok and works well. It's indeed a good base example of the simplest case.
I would only change the usage of t() function at the current state, the rest is a good start!
it's better to use the $this->t(), because global functions will be gone at some point and the FormBase takes the StringTranslationTrait which provides the method
the other t()
t()
Comment #10
kalinchernev CreditAttribution: kalinchernev commentedComment #11
kalinchernev CreditAttribution: kalinchernev commentedOn another note, there are 23 more hook_menu items which can also be converted, and I could take on some.
@Mile23, do you think it will be better to continue with patches on same path 1:1 scenarios, or we can re-group scenarios into longer form with more examples? The question basically is if any reorganization is planned anyway
Comment #12
Mile23OK, so a review of the patch includes:
I can't see the link in the tool menu when I enable the module.
Aside from that, to address #11: The idea is to do a straight port as much as is feasible. We want each example to be as simple to read as possible; putting a lot of them together in a controller might confuse the issue. Remember the point here is to instruct people on how to do these things in a clear way.
Comment #13
joachim CreditAttribution: joachim commentedI'm a bit confused by this patch, as it doesn't seem to be a straight port of the D7 module.
- The 'Choose something and explain why' form doesn't seem to exist on D7
- The D7 module contains several other AJAX forms.
Not sure what should be done here.
Anyway, in the meantime, here's an update of patch #2 with these issues fixed:
> It's better to use the $this->t(), because global functions will be gone at some point
> I can't see the link in the tool menu when I enable the module.
Comment #14
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedAgreed to @joachim,
If we look here : http://cgit.drupalcode.org/examples/tree/ajax_example/ajax_example.modul...
There are several ajax examples previously in D7 version of Ajax Example.
@Mile23, What do you think, if want simplest version. I can go ahead and test patch given in #13.
Comment #15
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedHi @Mile23,
I somehow faced an issue of
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "ajax_example" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 193 of /core/lib/Drupal/Core/Routing/Route
with patch submitted in #13.So, I have created a new patch which also replaces underscores with hyphens in path. Also, added
$this->t()
as suggest in #9.Comment #16
Manav CreditAttribution: Manav as a volunteer and at QED42 commentedThis patch works fine for me.
Comment #17
Mile23OK, so we have here a small piece of a port. It does demonstrate some use of AJAX, but doesn't port the rest of the example.
Assuming we're OK with only porting a little piece of it, here's a review. Consult #2209627: [meta] Module Checklist for Examples for some more stuff to consider.
We don't have a link in the tools menu for the AJAX page.
We don't have an assertion that there's a link in the tools menu.
We don't have any tests of the behavior of the page, such as to demonstrate that the page form even displays.
We now have javascript functional tests, which we could use on this example: https://api.drupal.org/api/drupal/core%21tests%21Drupal%21FunctionalJava... However, just a straight port of the D7 ajax_example tests would be good enough for now.
As far as how we split all this up into controller classes, I think just one controller with many methods would be fine for a documentation project such as this. If they could be chunked out into related types, that'd be great, but it's not essential.
Comment #18
pfrenssenThis is not good practice, it's better to wrap the textfield in a container than directly injecting HTML like this.
See AjaxFormsTestSimpleForm for an example.
I would also not call this element 'replace_textfield_div', but instead give it a semantically correct name.
Comment #19
Lal_This is the progress bar Ajax example. Well the example is not completely working, I am having some Ajax errors...
Comment #20
Lal_This is patch consist of Generate check boxes example, Generate text field, Submit-driven AJAX, Dependent dropdown, Dependent dropdown (with graceful degradation), Dependent dropdown with javascript off. But I am still stuck with
Progress bar example which I've mentioned in the comment #19
Submit function is not working for the Dependent dropdown (with graceful degradation), Dependent dropdown with javascript off.
Comment #21
Mile23Comment #22
Lal_I am still working for a perfect patch... https://github.com/abhilal007/AJAX-example , you can find it here
Comment #23
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #24
Lal_I was able complete few examples... but I am currently facing issues with the wizard and progress bar examples which is not working on the above patch...
Comment #26
Lal_Comment #27
Lal_Comment #29
Lal_This patch consist of AJAX advanced example.. but I am having some problems at two parts (forms) of the
1) ajax_example_advanced_commands_css_callback (the box is not created at the styles)
2) ajax_example_advanced_commands_restripe_num_rows , this function is also not working...
remaining function seems to be work properly...
also the progress bar example is not working properly and the Wizard is working partially
Comment #30
Lal_I was able to port the most of the example :-
1) AJAX framework commands
2) Add more button (with graceful degradation) w/JS turned off
3) Ajax Add more button
4) Ajax Wizard Example
5) Ajax Wizard Example w/JS turned off
6) Contextual Links Example
7) Dependent dropdown
8) Dependent dropdown degardes
9) Dependent dropdown degardes w/JS turned off
10) Dynamic Sections (with graceful degradation)
11) Dynamic Sections (with graceful degradation) w/js turned off
12) Generate checkboxes
13) Generate textfields
14) Simplest AJAX Example
15) Submit-driven AJAX
these examples are working correctly (Wizard example have few problem but it runs).
The remaining example I have attached the code inside the patch but they have few errors.
Comment #31
Mile23Comment #33
Lal_Documentation and fixed few errors but the problems still persist...
Comment #34
Lal_Comment #36
Mile23The testbot says:
Comment #37
Lal_Comment #38
Lal_The module still persist with the error mentioned in the #30
Comment #39
piyuesh23 CreditAttribution: piyuesh23 at QED42 commentedUpdated patch to add ajax example link to the toolbar & description page to list all the ajax examples. The patch also fixes the route names for the routes being listed on the description page.
Additionally, it would be great if we can outline the list of pending items around the port & update the summary/create child issues.
Comment #40
Lal_@piyuesh23
1) Wizard Example
2) Progress bar examples
3) Autocomplete examples
4) NodeFormAlter examples
5) Uniquecomplete examples
These examples are currently facing few errors and some have problems while running. Can you please take a look at the code...
Comment #41
Mile23Could you be more specific about the errors, so that @piyuesh23 can zero in on them? Thanks.
Comment #42
Mile23A ton of cleanup and a minimal test.
I'll probably be splitting this out into the parts that work, with a follow-up to add the parts that currently don't.
This is the list of the routes from the test, showing which routes are reliable:
Comment #43
Mile23Forgot the interdiff.
Comment #44
Mile23Hmm. Let's try that again.
Comment #45
Mile23Still working on this...
Comment #46
Mile23This patch removes quite a number of the examples, and we'll have a follow-up to add them back.
The interdiff is pretty huge. :-)
Comment #47
Mile23What is it with me and interdiffs?
Comment #48
Mile23Very minor code cleanup for simplest example.
Added two JS functional tests.
Comment #49
Mile23Lots of pruning and improvements.
Comment #50
Mile23More pruning, rearranging, making links work on pages, managing path parameters.
This is pretty close, and I'll likely commit it if the tests are green on the testbot. Then we'll start on the follow-ups.
Comment #52
Mile23Committed and pushed! Thanks, folks.
Follow-ups: #2928719: [meta] Add remaining AJAX examples from conversion #2928720: Add JS functional tests for each untested form in ajax_example
Comment #53
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedThanks @Mile23 for cleaning up and committing it.
Comment #54
Lal_Ahh... Feels awesome... @Mile23 thank you for your help... @navneet0693 thank you for mentoring me...