Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from Kdyby\FormsReplicator 1.x #112

Open
JanK007 opened this issue Sep 12, 2024 · 2 comments
Open

Upgrade from Kdyby\FormsReplicator 1.x #112

JanK007 opened this issue Sep 12, 2024 · 2 comments

Comments

@JanK007
Copy link

JanK007 commented Sep 12, 2024

Hello everybody,

I was tasked with upgrading an old application written in PHP 5.6 and Nette 2.3 to PHP 8.1+. I gradually replaced individual libraries and got to PHP 8.1, Nette 3.1 (unfortunately to Nette\Utils 4) but stayed at Latte 2. Unfortunately Nette\Utils 4 blocks me from using the old Kdyby\FormsReplicator.
I found the Contributte\Forms-multiplier library. Unfortunately, due to using Latte 2, I cannot use a higher version of the library than 3.2. In this version, I tried the default examples that worked me, but I ran into a few problems in the application that I can't quite get around:

  1. when setting default values ​​to the replicator when rendering the form, the defined buttons do not see it:
    Multiplier->detachCreateButtons(): void
    Nette\InvalidArgumentException: Component with name 'multiplier_creator' does not exist
    (apparently they are not yet added to the appropriate container)

  2. I did not manage to define nested multipliers (multiplier in multiplier) even in the test case, which it used several times in that application

  3. custom rendering (not through the macros) of repeatable components within the template is not working for me

Can Contributte\Forms-multiplier in version 3.2 even solve these problems?
Would switching to Latte 3 and thus the possibility of upgrading the library to version 4.* help me? Can a newer version of the library address these issues?
Should I use some other library?
Any other advices or examples?

I will be very grateful for any good advice.
Thank you.

@jtojnar
Copy link
Collaborator

jtojnar commented Sep 12, 2024

Unfortunately, we do not have resources to support the older versions. I can barely scrounge up enough time to maintain the primary version.

when setting default values ​​to the replicator when rendering the form, the defined buttons do not see it:
Multiplier->detachCreateButtons(): void
Nette\InvalidArgumentException: Component with name 'multiplier_creator' does not exist
(apparently they are not yet added to the appropriate container)

It is not clear to me what you mean. It would be helpful if you could create a minimal reproducible example against 4.0/master.

I did not manage to define nested multipliers (multiplier in multiplier) even in the test case, which it used several times in that application

Nested multipliers are known to be buggy in some cases. I wanted to fix that after #103 but other projects took priority.

custom rendering (not through the macros) of repeatable components within the template is not working for me

Not sure what you mean.

I found the Contributte\Forms-multiplier library. Unfortunately, due to using Latte 2, I cannot use a higher version of the library than 3.2.

If you do not use the latte macros and register the class manually, instead of using the DI extension. Latte is not actually required so you might be able to install it by removing the conflict:

"latte/latte": "<3.0.0",

Should I use some other library?

Unfortunately, I am not aware of any. I became a (partial) maintainer of this project because I also needed to upgrade a project that depended on Kdyby\FormsReplicator. But the project itself is minor thing I do in a free time so I can only spend so much time on maintaining its dependencies.

If your project depends on component like this you could also consider contributing fixes here.

@JanK007
Copy link
Author

JanK007 commented Sep 13, 2024

First of all, thank you for your reply. I programmer but not very familiar in PHP/Nette technologies. I work in PHP/Nette maximally several weeks per year.

It is not clear to me what you mean. It would be helpful if you could create a minimal reproducible example against 4.0/master.

I tried to create some simple example. It seems that it works with latest version. So I will see if it will be possible to upgrade.
I have yet only one problem with empty multiplier that has in my page 1 empty record. That is unwanted. I tried to remove it by setting minCopies to 0 or setValues to empty array but unsuccessfully.

...
$multiplier->setMinCopies(0);
...
$multiplier->setValues([], true);
...

Nested multipliers are #56 in some cases. I wanted to fix that after #103 but other projects took priority.

Can you specify what is the time we are talking about? Weeks, months? First quarter of next year?

custom rendering (not through the macros)

I mean "manual rendering" in latte template: Kdyby/FormsReplicator. It works me now with version 4.0/master.

If you do not use the latte macros and register the class manually, instead of using the DI extension.

Can you write your idea more explicitly? Download library separately, add to project manually and manually register Multiplier::class into Nette? Can you give me some advice/link how to do it?

Thank you very much for your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants