Magento2 order form: how to display the value of the placeholder attribute in the fields?

Hidden stock

I am setting up a check for one page in Magento 2. Now I am trying to display placeholders instead of labels in the delivery-address form, but have not achieved anything so far. Hope someone can help me.

Greetings, Jorge

UPDATE:

In the console, I see that the variable provides a placeholder attribute for the input element.

<input class="input-text" type="text" data-bind=" value: value, valueUpdate: 'keyup', hasFocus: focused, attr: { name: inputName, placeholder: placeholder, // <<<< right here 'aria-describedby': noticeId, id: uid, disabled: disabled }" name="street[0]" placeholder="" aria-describedby="notice-BVWUCFN" id="BVWUCFN"> 

Now, I would like to know if theres a way to change this variable through the backend, so I can display the label name in placeholder attr. See screenshot

Apolitics for my bad English

+5
source share
4 answers

Standard way

Copy all html files from vendor/magento/module-ui/view/frontend/web/templates/form/element/ to app/design/frontend/<Vendor>/<theme>/Magento_Ui/web/templates/form/element/

Then change everything. Change placeholder: placeholder to placeholder: label as a reference to Akis Verillis .

Now you need to deploy the static files using the code below:

  php bin/magento setup:static-content:deploy 

And see the magic.

Note. If you have a check from github, try copying from

 /app/code/Magento/Ui/view/base/web/templates/form/element/ 
+4
source

Change placeholder: placeholder to placeholder: label

+3
source

Now the answer to Magneto 2 documentation is: http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_edit_form.html Patterns are listed in previous answers. Templates from the magento-ui module are used in places other than statements.

In your custom module directory, create a new file / view / frontend / layout / checkout _index_index.xml. In this file, add content similar to the following:

 ... <referenceBlock name="checkout.root"> <arguments> <argument name="jsLayout" xsi:type="array"> ... <item name="shippingAddress" xsi:type="array"> <item name="children" xsi:type="array"> <!-- The name of the form the field belongs to --> <item name="shipping-address-fieldset" xsi:type="array"> <item name="children" xsi:type="array"> <!-- the field you are customizing --> <item name="telephone" xsi:type="array"> <item name="config" xsi:type="array"> <!-- Assigning a new template --> <item name="elementTmpl" xsi:type="string">%Vendor_Module%/form/element/%your_template%</item> 

%Vendor_Module%/form/element/%your_template% path [your subject dir] /Vendor_Module/web/template/form/element/your_template.html

Clear browser cache: Delete all files in the pub / static / frontend and var / view_preprocessing directories.

+2
source

If this is useful to you, the definition of this element is /app/code/Magento/Ui/view/base/web/templates/form/element/input.html It defines the input as:

 <input class="admin__control-text" type="text" data-bind=" value: value, hasFocus: focused, attr: { name: inputName, placeholder: placeholder, 'aria-describedby': noticeId, id: uid, disabled: disabled }" /> 
+1
source

Source: https://habr.com/ru/post/1243043/


All Articles