Tony's Blog

Magento 2 Add a note under a form field using ui components

  • In php code:
  1. $fieldset->addField(
  2. 'url',
  3. 'text',
  4. [
  5. 'name' => 'url',
  6. 'label' => __('URL'),
  7. 'title' => __('URL'),
  8. 'required' => false,
  9. 'note' => 'Can be an absolute or relative path.'
  10. ]
  11. );
  • In Ui Form:
  1. <item name="notice" xsi:type="string" translate="true">

example:

  1. <field name="sku">
  2. <argument name="data" xsi:type="array">
  3. <item name="config" xsi:type="array">
  4. <item name="label" xsi:type="string" translate="true">Sku</item>
  5. <item name="visible" xsi:type="boolean">true</item>
  6. <item name="dataType" xsi:type="string">text</item>
  7. <item name="formElement" xsi:type="string">input</item>
  8. <item name="source" xsi:type="string">product_information</item>
  9. <item name="dataScope" xsi:type="string">sku</item>
  10. <item name="disabled" xsi:type="boolean">true</item>
  11. <item name="notice" xsi:type="string" translate="true">Auto Created</item>
  12. <item name="validation" xsi:type="array">
  13. <item name="required-entry" xsi:type="boolean">true</item>
  14. </item>
  15. </item>
  16. </argument>
  17. </field>

Tony's blog image
More Magento 2 Document, Please View https://www.abmbio.xin/category/6