2

I am using EasyAmdinBundle 3 and I have the following CRUD Controller where the "plainPassword" field is a repeated field:

class UserCrudController extends AbstractCrudController
{
    public static function getEntityFqcn(): string
    {
        return User::class;
    }

    public function configureFields(string $pageName): iterable
    {
        yield TextField::new('username');

        $plainPasswordField = TextField::new('plainPassword')
            ->setFormType(RepeatedType::class)
            ->setFormTypeOptions([
                'type' => PasswordType::class,
                'first_options'  => ['label' => 'Password'],
                'second_options' => ['label' => 'Repeat Password'],
            ])
            ->hideOnIndex()
        ;

        if ($pageName === Action::NEW) {
            $plainPasswordField->setRequired(true);
        }

        yield $plainPasswordField;
    }
}

The field is repeated as expected. However, the length of the field is the full width. The other fields are only half that length ("col-sm-6").

I alreade tried setColumns(6) and setCssClass('col-sm-6') on $plainPasswordField but it did not help.

Does anybody know how to set the width of a repeated field in EasyAdminBundle 3?

Jayster
  • 61
  • 6

1 Answers1

3

You need to put the class attribute into the row_attr property of first and second options:

TextField::new('plainPassword')
     ->onlyOnForms()
     ->setFormType(RepeatedType::class)
     ->setFormTypeOptions([
         'type'           => PasswordType::class,
         'first_options'  => [
             'label'    => 'New Password',
             'row_attr' => [
                 'class' => 'col-md-6 col-xxl-5',
             ],
         ],
         'second_options' => [
             'label'    => 'Repeat Password',
             'row_attr' => [
                 'class' => 'col-md-6 col-xxl-5',
             ],
         ],
     ],
 ),
Mateng
  • 3,742
  • 5
  • 37
  • 64
  • so the div wrapping the input has those classes applied - but not the wrapping div as is the case with the other form elements for example : https://imgur.com/a/33oDrOe <-- screenshot of classes applied – virtualLast Jan 10 '23 at 13:14