0

I have a form in the store -> configuration what I've created in my system.xml.

Before save I want to validate it. When an error happens, I want to inform the user what field was not valid.

How can I read out the label of the field from a Magento\Framework\App\Config\Value in the beforeSave method?

Now I can read out like this:

$label = $this->getData('field_config')['label'];

But is this the proper way to get the label? Isn't there a method or cleaner way to do it?

  • What kind of validation you required ? What kind of input you are using? – Pawan Mar 18 '18 at 8:12
  • I am using custom frontend_model to show 2 fields. This 2 fields are in one row, I have a set of theese. I need to get a name and a hexa color for css. When I validate in the backend_model, I want to show what was the label of the bad value(s). – vaso123 Mar 18 '18 at 8:43

Your Answer

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

Browse other questions tagged or ask your own question.