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

use specific language_name in a ChildForm Collection #728

Closed
ELtd opened this issue Oct 23, 2024 · 2 comments
Closed

use specific language_name in a ChildForm Collection #728

ELtd opened this issue Oct 23, 2024 · 2 comments

Comments

@ELtd
Copy link
Contributor

ELtd commented Oct 23, 2024

Hello,

I use a specific form in two collections.
I don't want to have the same labels in the two.
We should be able to force the language name in the options of the collection.

Form A [
      Collection A1 [
            Form B
       ],
      Collection A2[
            Form B
       ]
]

To fix the problem :

'language_name' => $this->parent->getLanguageName(),

- 'language_name' => $this->parent->getLanguageName(),
+ 'language_name' => $this->getOption('language_name') ?: $this->parent->getLanguageName(),

Then this code works as expected :

$this->add('A1', 'collection',
        [
            'type' => 'form',
            'options' => [
                'class' => B::class,
                'language_name'=>'models.A1.B',
            ]
        ]);

Thank you for your package !

@rudiedirkx
Copy link
Collaborator

Looks good. PR please.

I never use the 'language name' - I always explicitly set label for every field - so I can't test it, but it looks safe enough.

@rudiedirkx
Copy link
Collaborator

Fixed in #729

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

No branches or pull requests

2 participants