user14999068
user14999068

Reputation:

Symfony EasyAdminBundle 3 repeated field length

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?

Upvotes: 3

Views: 588

Answers (1)

Mateng
Mateng

Reputation: 3734

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',
             ],
         ],
     ],
 ),

Upvotes: 2

Related Questions