0

I have below code

$this->addColumn(
                    'qty[]', [
                'header' => __('Qty'),
                'type' => 'number',
                'index' => 'qty',
                'editor' => 'text',
                'class' => 'validate-number',
                    ]
            );

How to validate this field. I need to validate for only numbers allowed?

1

Simply add:

'validate_class' => 'validate-number',

Take a look: vendor/magento/module-sales/Block/Adminhtml/Order/Create/Search/Grid.php

  • Hi @Khoa If u look at Admin Create Order functionality & inspect actually class is not applying & They are doing validation on server side Strange. So what's need to apply this – Ankit Shah Mar 31 '17 at 3:24
  • On server side how to validate it? – Ankit Shah Mar 31 '17 at 3:29
  • Okay! Let me try. – Khoa TruongDinh Mar 31 '17 at 3:30
  • How you create this custom field? it is a custom attribute? – Khoa TruongDinh Mar 31 '17 at 3:36
  • This is listing field. Not attribute – Ankit Shah Mar 31 '17 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.