2

I am creating field by using this code in my system.xml file of custom module

<field id="SenderCity" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Physical address</label>
    <validate>required-entry</validate>
</field>

The result of this code is as:

enter image description here

Now i want to add placeholder for that custom field. Should i use some custom JS or is there any tag for placeholder?

3
  • you need a placeholder or a default value?
    – Altravista
    Commented Nov 1, 2018 at 12:38
  • need only placeholder Commented Nov 1, 2018 at 12:42
  • @iqbalmalik I think you can add comment to add field description. If you want placeholder then it would required additional customization. See my answer if you wants to add field description.. Commented Nov 1, 2018 at 12:47

2 Answers 2

1

Magento does not have tag file <placeholder></placeholder> for system.xml which will render as placeholder HTML tag.

If you want to add a placeHolder folder button then you have to create <frontend_model> for this field.

See https://belvg.com/blog/how-to-add-custom-system-configuration-elements-in-magento-2-0.html

0

You can add comment to particular field, are you looking something like that?

<comment>Add your field description</comment>

So in your case, it would be like

<field id="SenderCity" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Physical address</label>
    <validate>required-entry</validate>
    <comment>Add your field description</comment>
</field>
3
  • i need placeholder not comment. comment shows under field but i am in need of placeholder inside field Commented Nov 1, 2018 at 12:46
  • Ok, in that case you can add default values which would be shown when no value is saved.. follow this article for more details magestandard.com/configure-default-field-values-magento-2 Commented Nov 1, 2018 at 12:51
  • see below xml files for further details vendor/magento/module-catalog/etc/system.xml and vendor/magento/module-catalog/etc/config.xml Commented Nov 1, 2018 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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