Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-29825

As a dev, I want to be able to override content edit form fields for specific Content Types

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: High High
    • 2.4.0-beta1
    • 2.3.2
    • None

    Description

      Hello,

      Customer is asking how to customize some edit form fields when editing a Content of a specific ContentType (let's say article for example).
      In legacy this was done by something like:

      [edit_article_title]
      Source=content/datatype/edit/ezstring.tpl
      MatchFile=content/datatype/edit/article_title.tpl
      Match[class_identifier]=article
      Match[attribute_identifier]=title
      

      According to me (but I'm maybe missing something here), this could be easily done using the ViewProvider on the content_edit_view with a specific `form_templates` parameter. This form_templates parameter is an array of templates' paths and will be used to define the form_theme with the `default_form_templates`. This is done here : https://github.com/ezsystems/ezplatform-admin-ui/blob/master/src/bundle/Resources/views/content/content_edit/content_edit_base.html.twig#L4

      So to give a concrete example I would have something like this to override some edit form fields for 'Article' Contents :

      Unable to find source-code formatter for language: ymll. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      system:
          admin_group:
                  content_edit_view:
                      full:
                          ezplatform_admin_ui_article:
                              template: '@ezdesign/content/content_edit/content_edit.html.twig'
                              match:
                                  Identifier\ContentType: [article]
                              params:
                                  viewbaseLayout: '@ezdesign/layout.html.twig'
                                  form_templates: ["@ezdesign/content/content_edit/article_form_fields.html.twig"]
                          ezplatform_admin_ui:
                          template: '@ezdesign/content/content_edit/content_edit.html.twig'
                          match: true
                          params:
                              viewbaseLayout: '@ezdesign/layout.html.twig'
      
      

      with 'article_form_fields.html.twig' having some specific form fragments to use (pure symfony here, no need to be exposed).

      Untill here evrything is ok.

      The issue I'm having here is that `form_templates` (here containing 'article_form_fields.html.twig' path) will be merged with the default_form_templates ( see github repo link above ) in a way that custom form templates can't override default form templates :

      Actual version :

      form_templates|merge(default_form_templates)

      (so default_form_templates will be added AFTER form_template in the new array)

      Needed version :

      default_form_templates|merge(form_templates)

      Here our custom form templates will be able to override the standard form templates in the `form_theme` because default form_templates will be BEFORE in the merged array.

      And from my understanding and manual tests done, this is not giving side effects on other parts of the admin.

      Long story for short fix...

      Attachments

        Activity

          People

            Unassigned Unassigned
            stephane.diot-obsolete@ez.no Stéphane Diot (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: