Skip to content
Snippets Groups Projects
Commit 6eee654f authored by Leo Kacenjar's avatar Leo Kacenjar Committed by Jonathan Sacksick
Browse files

Issue #3400651 by lkacenja Inline errors on price field are not visible.

parent 55743fef
No related branches found
No related tags found
3 merge requests!235Issue #3115150 by mbovan: Submitting add to cart form with empty quantity...,!205Issue #3349465 by tBKoT, jsacksick, bojanz: Update several VAT rates and setup...,!192Issue #3121168 by Neograph734, longwave, lisastreeter: Include the store name...
Pipeline #51401 canceled
......@@ -45,9 +45,6 @@ class Price extends FormElement {
'#attached' => [
'library' => ['commerce_price/admin'],
],
'#element_validate' => [
[$class, 'moveInlineErrors'],
],
'#process' => [
[$class, 'processElement'],
[$class, 'processAjaxForm'],
......@@ -123,7 +120,6 @@ class Price extends FormElement {
'#maxlength' => $element['#maxlength'],
'#min_fraction_digits' => min($fraction_digits),
'#min' => $element['#allow_negative'] ? NULL : 0,
'#error_no_message' => TRUE,
'#description' => t('Format: @format', ['@format' => $number_formatter->format('9.99')]),
];
if (isset($element['#ajax'])) {
......@@ -185,24 +181,4 @@ class Price extends FormElement {
return TRUE;
}
/**
* Moves inline errors from the "number" element to the main element.
*
* This ensures that they are displayed in the right place
* (below both number and currency_code, instead of between them).
*
* Only performed when the inline_form_errors module is installed.
*
* @param array $element
* The form element.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public static function moveInlineErrors(array $element, FormStateInterface $form_state) {
$error = $form_state->getError($element['number']);
if (!empty($error) && !empty($element['#price_inline_errors'])) {
$form_state->setError($element, $error);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment