Skip to content

Commit 9a185b1

Browse files
committed
Merge branch 'MAGETWO-45055' of github.corp.magento.com:magento-vanilla/magento2ce into PR
2 parents 180ca97 + 023b792 commit 9a185b1

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/options.phtml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/** @var $block \Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\Options */
1010
?>
11-
<fieldset class="fieldset ignore-validate">
11+
<fieldset class="fieldset">
1212
<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Options (values of your attribute)') ?></span></legend>
1313
<div id="manage-options-panel">
1414
<table class="admin__control-table">
@@ -27,8 +27,14 @@
2727
<th class="col-delete">&nbsp;</th>
2828
</tr>
2929
</thead>
30-
<tbody data-role="options-container"></tbody>
30+
<tbody data-role="options-container" class="ignore-validate"></tbody>
3131
<tfoot>
32+
<tr>
33+
<th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="validation">
34+
<input type="hidden" class="required-dropdown-attribute-entry" name="dropdown_attribute_validation"/>
35+
</th>
36+
</tr>
37+
<tr>
3238
<th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add">
3339
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?>
3440
<button id="add_new_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Option'); ?>"
@@ -37,6 +43,7 @@
3743
</button>
3844
<?php endif; ?>
3945
</th>
46+
</tr>
4047
</tfoot>
4148
</table>
4249
<input type="hidden" id="option-count-check" value="" />

app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<tfoot>
3838
<tr>
3939
<th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>">
40-
<input type="hidden" class="required-swatch-entry"/>
40+
<input type="hidden" class="required-text-swatch-entry" name="text_swatch_validation"/>
4141
</th>
4242
</tr>
4343
<tr>

app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<tfoot>
3434
<tr>
3535
<th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>">
36-
<input type="hidden" class="required-swatch-entry"/>
36+
<input type="hidden" class="required-visual-swatch-entry" name="visual_swatch_validation"/>
3737
</th>
3838
</tr>
3939
<tr>

app/design/adminhtml/Magento/backend/web/css/source/forms/fields/_control-table.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
tfoot {
3333
th {
3434
padding-bottom: @control-table-cell__padding-vertical;
35+
&.validation {
36+
padding-bottom: 0;
37+
padding-top: 0;
38+
}
3539
}
3640
}
3741
tr {

lib/web/mage/validation.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,23 @@
141141
}
142142

143143
/**
144+
* validate all table required inputs at once, using single hidden input
145+
* @param {String} value
146+
* @param {HTMLElement} element
147+
*
148+
* @return {Boolean}
149+
*/
150+
function tableSingleValidation (value, element) {
151+
var empty = $(element).closest('table')
152+
.find('input.required-option:visible')
153+
.filter(function(i, el){
154+
return $.mage.isEmpty(el.value);
155+
})
156+
.length;
157+
return empty === 0;
158+
}
159+
160+
/**
144161
* Collection of validation rules including rules from additional-methods.js
145162
* @type {Object}
146163
*/
@@ -1239,16 +1256,17 @@
12391256
},
12401257
'Please enter a valid number.'
12411258
],
1242-
'required-swatch-entry': [
1243-
function (value, element) {
1244-
var empty = $(element).closest('table')
1245-
.find('input.required-option:visible')
1246-
.filter(function(i, el){
1247-
return $.mage.isEmpty(el.value);
1248-
})
1249-
.length;
1250-
return empty === 0;
1251-
}, 'Admin is a required field in the each row.'
1259+
'required-text-swatch-entry': [
1260+
tableSingleValidation,
1261+
'Swatch and Admin are the required fields in the each row.'
1262+
],
1263+
'required-visual-swatch-entry': [
1264+
tableSingleValidation,
1265+
'Admin is a required field in the each row.'
1266+
],
1267+
'required-dropdown-attribute-entry': [
1268+
tableSingleValidation,
1269+
'Admin is a required field in the each row.'
12521270
],
12531271
'validate-item-quantity': [
12541272
function (value, element, params) {

0 commit comments

Comments
 (0)