Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-699

Not required empty block field prevents submission of configure popup

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: High High
    • Resolution: Fixed
    • Affects Version/s: 16.02, Customer request
    • Fix Version/s: 16.04, 1.3.1, 1.4.0-beta1
    • Component/s: Studio UI
    • Labels:
      None

      Description

      Create a new basic block with two embed Block attributes.
      Make the first attribute required.
      Make the second one optional.

      Add the block to a zone and click the configure button.
      Add an item to the required attribute and leave the other one empty as default.

      Clicking on submit shakes the dialog box indicating an error, but no error message is displayed.

        Issue Links

          Activity

          Peter Halasz created issue -
          Kamil Musiał (Inactive) made changes -
          Field Original Value New Value
          Assignee Kamil Musiał [ kamil.musial@ez.no ]
          Kamil Musiał (Inactive) made changes -
          Status Open [ 1 ] Confirmed [ 10037 ]
          Hide
          Kamil Musiał (Inactive) added a comment - - edited

          I cannot reproduce this bug. Everything works fine in my env. Please provide your block class and services.yml file with config of this service.

          Show
          Kamil Musiał (Inactive) added a comment - - edited I cannot reproduce this bug. Everything works fine in my env. Please provide your block class and services.yml file with config of this service.
          Hide
          Peter Halasz added a comment - - edited

          The block class for the block with the issues:

          <?php
           
          namespace Example\EzStudio\FieldType\LandingPage\Model\Block;
           
          use eZ\Publish\API\Repository\ContentService;
          use EzSystems\LandingPageFieldTypeBundle\Exception\InvalidBlockAttributeException;
          use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockDefinition;
          use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockAttributeDefinition;
          use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\AbstractBlockType;
          use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockType;
          use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockValue;
           
          /**
           * List Card block
           * Renders content from given location.
           */
          class ListCardBlock extends AbstractBlockType implements BlockType
          {
              /**
               * @var ContentService
               */
              private $contentService;
           
              /**
               * @param ContentService $contentService
               */
              public function __construct(ContentService $contentService)
              {
                  $this->contentService = $contentService;
              }
           
              /**
               * {@inheritdoc}
               */
              public function getTemplateParameters(BlockValue $blockValue)
              {
                  $attributes = array_filter($blockValue->getAttributes(), function ($attribute) {
                      return !empty($attribute);
                  });
           
                  $articleLocationIds = array_map(function ($attribute) {
                      return $this->contentService->loadContentInfo($attribute)->mainLocationId;
                  }, $attributes);
           
                  return ['articleLocationIds' => $articleLocationIds];
              }
           
              /**
               * {@inheritdoc}
               */
              public function createBlockDefinition()
              {
                  $blockAttributeDefinitions = array_map(function ($index) {
                      return new BlockAttributeDefinition(
                          sprintf('article_%d_Id', $index),
                          sprintf('Article %d', $index),
                          'embed',
                          '/^([a-zA-Z]:)?(\/[a-zA-Z0-9_\/-]+)+\/?/',
                          'Choose an Article',
                          $index == 1
                      );
                  }, range(1, 4));
           
                  return new BlockDefinition(
                      'listcard',
                      'List Card',
                      'default',
                      'bundles/ezsystemslandingpagefieldtype/images/thumbnails/contentlist.svg',
                      [],
                      $blockAttributeDefinitions
                  );
              }
           
              /**
               * {@inheritdoc}
               */
              public function checkAttributesStructure(array $attributes)
              {
                  if (!isset($attributes['article_1_Id'])) {
                      throw new InvalidBlockAttributeException('ListCard', 'article_1_Id', 'You need to select at least 1 item.');
                  }
           
                  if (!is_numeric($attributes['article_1_Id'])) {
                      throw new InvalidBlockAttributeException('ListCard', 'article_1_Id', 'Content ID must be type of integer.');
                  }
              }
          }
          

          Part from the services configuration for the block:

          <service id="ezpublish.landing_page.block.list_card" class="Example\EzStudio\FieldType\LandingPage\Model\Block\ListCardBlock">
                  <argument type="service" id="ezpublish.api.service.content"/>
           
                  <tag name="landing_page_field_type.block_type" alias="listcard"/>
          </service>
          

          Show
          Peter Halasz added a comment - - edited The block class for the block with the issues: <?php   namespace Example\EzStudio\FieldType\LandingPage\Model\Block;   use eZ\Publish\API\Repository\ContentService; use EzSystems\LandingPageFieldTypeBundle\Exception\InvalidBlockAttributeException; use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockDefinition; use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockAttributeDefinition; use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\AbstractBlockType; use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockType; use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockValue;   /** * List Card block * Renders content from given location. */ class ListCardBlock extends AbstractBlockType implements BlockType { /** * @var ContentService */ private $contentService;   /** * @param ContentService $contentService */ public function __construct(ContentService $contentService) { $this->contentService = $contentService; }   /** * {@inheritdoc} */ public function getTemplateParameters(BlockValue $blockValue) { $attributes = array_filter($blockValue->getAttributes(), function ($attribute) { return !empty($attribute); });   $articleLocationIds = array_map(function ($attribute) { return $this->contentService->loadContentInfo($attribute)->mainLocationId; }, $attributes);   return ['articleLocationIds' => $articleLocationIds]; }   /** * {@inheritdoc} */ public function createBlockDefinition() { $blockAttributeDefinitions = array_map(function ($index) { return new BlockAttributeDefinition( sprintf('article_%d_Id', $index), sprintf('Article %d', $index), 'embed', '/^([a-zA-Z]:)?(\/[a-zA-Z0-9_\/-]+)+\/?/', 'Choose an Article', $index == 1 ); }, range(1, 4));   return new BlockDefinition( 'listcard', 'List Card', 'default', 'bundles/ezsystemslandingpagefieldtype/images/thumbnails/contentlist.svg', [], $blockAttributeDefinitions ); }   /** * {@inheritdoc} */ public function checkAttributesStructure(array $attributes) { if (!isset($attributes['article_1_Id'])) { throw new InvalidBlockAttributeException('ListCard', 'article_1_Id', 'You need to select at least 1 item.'); }   if (!is_numeric($attributes['article_1_Id'])) { throw new InvalidBlockAttributeException('ListCard', 'article_1_Id', 'Content ID must be type of integer.'); } } } Part from the services configuration for the block: <service id="ezpublish.landing_page.block.list_card" class="Example\EzStudio\FieldType\LandingPage\Model\Block\ListCardBlock"> <argument type="service" id="ezpublish.api.service.content"/>   <tag name="landing_page_field_type.block_type" alias="listcard"/> </service>
          Piotr Nalepa made changes -
          Assignee Kamil Musiał [ kamil.musial@ez.no ] Piotr Nalepa [ piotr.nalepa@ez.no ]
          Piotr Nalepa made changes -
          Status Confirmed [ 10037 ] InputQ [ 10001 ]
          Piotr Nalepa made changes -
          Status InputQ [ 10001 ] Development [ 3 ]
          André Rømcke made changes -
          Affects Version/s Customer request [ 14520 ]
          Show
          Piotr Nalepa added a comment - PR merged to 1.2: https://github.com/ezsystems/StudioUIBundle/commit/b51cadbd4578a264625891995d0f07b032a05520
          Piotr Nalepa made changes -
          Remote Link This issue links to "PR merged to 1.2 (Web Link)" [ 16608 ]
          Piotr Nalepa made changes -
          Status Development [ 3 ] Development Review [ 10006 ]
          Piotr Nalepa made changes -
          Status Development Review [ 10006 ] Documentation Review done [ 10011 ]
          Assignee Piotr Nalepa [ piotr.nalepa@ez.no ]
          Michał Szołtysek made changes -
          Status Documentation Review done [ 10011 ] QA [ 10008 ]
          Michał Szołtysek made changes -
          Affects Version/s 16.02 [ 14505 ]
          Michał Szołtysek made changes -
          Fix Version/s 16.04 [ 14518 ]
          Fix Version/s 1.4.0-beta1 [ 14531 ]
          Fix Version/s 1.3.1 [ 14529 ]
          Hide
          Michał Szołtysek added a comment -

          QA Approved

          Show
          Michał Szołtysek added a comment - QA Approved
          Michał Szołtysek made changes -
          Status QA [ 10008 ] QA done [ 10007 ]
          Assignee Michał Szołtysek [ michal.szoltysek@ez.no ]
          Michał Szołtysek made changes -
          Status QA done [ 10007 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Alex Schuster made changes -
          Workflow EZ* Development Workflow [ 98481 ] EZEE Development Workflow [ 105872 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Confirmed Confirmed
          7d 17h 11m 1 kamil.musial@ez.no 21/Apr/16 9:28 AM
          Confirmed Confirmed InputQ InputQ
          3h 39m 1 Piotr Nalepa 21/Apr/16 1:07 PM
          InputQ InputQ Development Development
          2s 1 Piotr Nalepa 21/Apr/16 1:07 PM
          Development Development Development Review Development Review
          59d 23h 39m 1 Piotr Nalepa 20/Jun/16 12:47 PM
          Development Review Development Review Documentation Review done Documentation Review done
          11s 1 Piotr Nalepa 20/Jun/16 12:47 PM
          Documentation Review done Documentation Review done QA QA
          3h 17m 1 Michał Szołtysek 20/Jun/16 4:04 PM
          QA QA QA Done QA Done
          19h 36m 1 Michał Szołtysek 21/Jun/16 11:41 AM
          QA Done QA Done Closed Closed
          23s 1 Michał Szołtysek 21/Jun/16 11:41 AM

            People

            • Assignee:
              Unassigned
              Reporter:
              Peter Halasz
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: