Easyadminbundle: Admin config file : unable to override form options in new or (edit) views

Created on 1 Oct 2016  路  9Comments  路  Source: EasyCorp/EasyAdminBundle

EasyAdmin : 1.15.1

I have the following admin configuration form my User entity:

    entities:
        User:
            class: FBN\UserBundle\Entity\User                 
            form:
                fields:
                    - 'username'
                    - 'email'
                    - { property: 'plainPassword', type: 'text', type_options: { required: false} }
                    - { property: 'roles', type: choice, type_options: { multiple: true, choices: { 'ROLE_USER': 'ROLE_USER', 'ROLE_ADMIN': 'ROLE_ADMIN' } } }
                    - 'enabled'
                    - 'locked'                
            new:
                fields:
                    - { property: 'plainPassword', type: 'text', type_options: { required: true} } 

When I create a new User (new view) I have only the field plainPassword. All others fields defined in form section are not displayed. I my edit view all fields are available.

Did I miss something in the doc ?

bug hasPR

Most helpful comment

@CruzyCruz the problem is that in this line we make an array_replace() instead of an array_replace_recursive():

form_override

The original intention was to allow granular overriding ... so maybe we could change it to *_recursive() (it shouldn't be a BC break because the new and edit configs always have preference over form)

All 9 comments

The code you suggested in your other issue should work

@Yunyun548

Yes it does because in #1312 I define both edit and new sections. Here, following the doc I thought I could override the property plainPassword without having to redefine other properties.

Could you close one of the issues and create a PR ? If you don't have time i'll gladly do it (:

@Yunyun548

Those two issues are differents. One is for reporting that I am not able to override some specific options following doc instructions. The other one is for proposing an improvement of the documentation.

I can try to create a PR for #1312 (doc improvement) but you will have to be indulgent as it will be my first PR :)

@CruzyCruz the problem is that in this line we make an array_replace() instead of an array_replace_recursive():

form_override

The original intention was to allow granular overriding ... so maybe we could change it to *_recursive() (it shouldn't be a BC break because the new and edit configs always have preference over form)

@javiereguiluz

I understand. Effectively, array_replace_recursive() would allow the wished granularity.

I was wrong. As shown in #1341, array_replace_recursive won't solve this problem because fields are defined in numeric arrays instead of associative arrays ... so a custom processing will be needed. I'll do that.

Ok, it makes sense.

Closing it as fixed by #1341

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joazvsoares picture joazvsoares  路  4Comments

lukasluecke picture lukasluecke  路  3Comments

cve picture cve  路  4Comments

bocharsky-bw picture bocharsky-bw  路  3Comments

Wait4Code picture Wait4Code  路  3Comments