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

Ability to add html attributes to crud pages #6231

Open
KDederichs opened this issue Mar 26, 2024 · 2 comments · May be fixed by #6232
Open

Ability to add html attributes to crud pages #6231

KDederichs opened this issue Mar 26, 2024 · 2 comments · May be fixed by #6232

Comments

@KDederichs
Copy link
Contributor

Short description of what this feature will allow to do:
Add ability to add html attributes to crud pages.

Example of how to use this feature
Would be useful to add Stimulus directives to CRUD pages (data-controller)

    #[\Override] public function configureCrud(Crud $crud): Crud
    {
        $crud->setHtmlAttribute('data-controller', 'clipboard');
        return $crud;
    }
@KDederichs KDederichs linked a pull request Mar 26, 2024 that will close this issue
@OcB974
Copy link

OcB974 commented Mar 29, 2024

Hello,

This solution works for me in my CrudController ( with "easycorp/easyadmin-bundle": "^4.9"):

public function configureCrud(Crud $crud): Crud
{
    $crud->setFormOptions([
        'attr' => [
            'data-controller' => 'coupon' // = <form data-controller="coupon" ...>
        ]
    ]);
 }
 
public function configureFields(string $pageName): iterable
{
  yield TextField::new('code', 'Code')
      ->setFormTypeOptions([
          'attr' => [
              'data-coupon-target' => 'input'
          ]
      ])
      ->setHelp('<a data-action="coupon#generate" class="btn btn-primary" href="#">Generate random code</a>')
  ;
}

@KDederichs
Copy link
Contributor Author

Sure I know that works on forms, but there's no form on index to attach the controller to.

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

Successfully merging a pull request may close this issue.

2 participants