diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml index 63af3ebae14bcd7e0610c47b1485aaecd5f5b19f..1cdb50d54a34da6ba0a617a4bd64de64bf10921c 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml @@ -8,7 +8,7 @@ /** @var $block \Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Text */ ?> -<fieldset class="fieldset ignore-validate"> +<fieldset class="fieldset"> <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Swatch (values of your attribute)') ?></span></legend> <div id="swatch-text-options-panel"> <?php //@todo move style to css file ?> @@ -33,16 +33,23 @@ <th class="col-delete"> </th> </tr> </thead> - <tbody data-role="swatch-text-options-container"></tbody> + <tbody data-role="swatch-text-options-container" class="ignore-validate"></tbody> <tfoot> - <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> - <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> - <button id="add_new_swatch_text_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" - type="button" class="action- scalable add"> - <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> - </button> - <?php endif; ?> - </th> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>"> + <input type="hidden" class="required-swatch-entry"/> + </th> + </tr> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> + <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> + <button id="add_new_swatch_text_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" + type="button" class="action- scalable add"> + <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> + </button> + <?php endif; ?> + </th> + </tr> </tfoot> </table> <input type="hidden" id="swatch-text-option-count-check" value="" /> diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml index a236cf00dd1ab38353d560feb986ed05001f0a96..3871ccda9a3efeff5c33fb93d60836c6c49de11e 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml @@ -8,7 +8,7 @@ /** @var $block \Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Visual */ ?> -<fieldset class="fieldset ignore-validate"> +<fieldset class="fieldset"> <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Swatch (values of your attribute)') ?></span></legend> <div id="swatch-visual-options-panel"> <?php //@todo move style to css file ?> @@ -29,16 +29,23 @@ <th class="col-delete"> </th> </tr> </thead> - <tbody data-role="swatch-visual-options-container"></tbody> + <tbody data-role="swatch-visual-options-container" class="ignore-validate"></tbody> <tfoot> - <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> - <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> - <button id="add_new_swatch_visual_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" - type="button" class="action- scalable add"> - <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> - </button> - <?php endif; ?> - </th> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>"> + <input type="hidden" class="required-swatch-entry"/> + </th> + </tr> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> + <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> + <button id="add_new_swatch_visual_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" + type="button" class="action- scalable add"> + <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> + </button> + <?php endif; ?> + </th> + </tr> </tfoot> </table> <input type="hidden" id="swatch-visual-option-count-check" value="" /> diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index 98240eb8cfa40797c4efd0e6c222397857ddb7bd..982a7ecf73ea05d3536eb3c831184ba5f1b7a008 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -1224,6 +1224,17 @@ }, 'Please enter a valid number.' ], + 'required-swatch-entry': [ + function (value, element) { + var empty = $(element).closest('table') + .find('input.required-option') + .filter(function(i, el){ + return $.mage.isEmpty(el.value); + }) + .length; + return empty === 0; + }, 'Admin is a required field in the each row.' + ], 'validate-item-quantity': [ function (value, element, params) { // obtain values for validation