Magento2 checkout form: How to display placeholder attribute value in fields? - input

Goodmorning Stackoverflow,
I'm customizing the checkout onepage in Magento 2. Now I'm trying to display placeholders instead of labels in the shipping-address form, but no success till now. I hope someone can help me out
Cheers, Jorge
UPDATE:
In the console i can see a variable is giving to the attribute placeholder of the element input.
<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 is a way to modify this variable via the backend, so i can display label name in the placeholder attr.
See screenshot
Apoligies for my bad english

Standard way,
Copy all html files from vendor/magento/module-ui/view/frontend/web/templates/form/element/
at
app/design/frontend/<Vendor>/<theme>/Magento_Ui/web/templates/form/element/
Then change all Change placeholder: placeholder to placeholder: label as mention by Akis Verillis.
Now you need to deploy the static files by below code:
php bin/magento setup:static-content:deploy
And see the magic.
Note: If you have checkout from github then try copy from
/app/code/Magento/Ui/view/base/web/templates/form/element/

Change placeholder: placeholder to placeholder: label

The answer is in Magneto 2 documentation now:
http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_edit_form.html
The templates are the ones mentioned in previous answers.
The templates from magento-ui module are used in other places than checkout.
In your custom module directory, create a new /view/frontend/layout/checkout_index_index.xml file. 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 is [your theme dir]/Vendor_Module/web/template/form/element/your_template.html
Clear browser cache too beside:
Delete all files in the pub/static/frontend and var/view_preprocessing directories.

If this is useful for you, the definition of that element is in:
/app/code/Magento/Ui/view/base/web/templates/form/element/input.html
It defines an 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
}" />

You can add placeholder item to a layout.xml file for your field. Just like this:
<item name="address" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="config" xsi:type="array">
<item name="customScope" xsi:type="string">contactForm</item>
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/input</item>
</item>
<item name="placeholder" xsi:type="string">Address</item>
<item name="dataScope" xsi:type="string">address</item>
<item name="label" xsi:type="string">Address</item>
<item name="sortOrder" xsi:type="string">20</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="string">true</item>
</item>

Related

How customize EditCustomfieldDefaults screen in my customfield plugin

I'm trying to override the default customfield value setting screen, but I'm unable to add the template.
The standard edit.vm template allows you to change the value of the field in the issue, but I need a separate page for this
enter image description here
My code from atlassian-plugin.xml
`
<customfield-type
name="Metro Cascading Custom Field"
i18n-name-key="metro-cascading-custom-field.name"
key="metro-cascading-custom-field"
class="MetroCascadingCustomField.MetroCascadingCustomField">
<description
key="metro-cascading-custom-field.description">The Metro Cascading Custom Field Plugin</description>
<resource name="view" type="velocity" location="/templates/customfields/metro-cascading-custom-field/view.vm"/>
<resource name="edit" type="velocity" location="/templates/customfields/metro-cascading-custom-field/edit.vm"/>
</customfield-type>
<webwork1
key="metro-cascading-cuastomfield-webwork"
name="Metro Cascading Cuastomfield Webwork"
i18n-name-key="metro-cascading-cuastomfield-webwork.name">
<description key="metro-cascading-cuastomfield-webwork.description">The Metro Cascading Cuastomfield Webwork Plugin</description>
<actions>
<action name="ru.jira.metro.plugin.jira.webwork.MetroCascadingCuastomfieldWebworkAction" alias="CustomMultiSelectOptionsConfiguration">>
<view name="success">/templates/metro-cascading-cuastomfield-webwork/success.vm</view>
<view name="input">/templates/metro-cascading-cuastomfield-webwork/input.vm</view>
<view name="error">/templates/metro-cascading-cuastomfield-webwork/error.vm</view>
</action>
</actions>
<context>atl.admin.custom-fields</context>
</webwork1>
`

How to tap on the three dot menu (more options) in the actionbar on Android using Detox?

How to tap on the three dot menu (more options) in the actionbar on Android using Detox?
I followed this SO answer, https://stackoverflow.com/a/65736139/3970346
Since this is a NativeScript app the steps are,
Create a ids.xml file under app/App_Resources/Android/src/main/res/values folder,
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="overflowActionButton"/>
</resources>
Then in the styles.xml in the same directory add,
<style name="Widget.ActionButton.Overflow" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:id">#id/overflowActionButton</item>
<item name="android:contentDescription">"overflowActionButton"</item>
<item name="android:tint">#color/white</item>
</style>
Finally set the style on the AppThemeBase like this,
<!-- theme to use AFTER launch screen is loaded-->
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<!-- the line below -->
<item name="actionOverflowButtonStyle">#style/Widget.ActionButton.Overflow</item>
</style>
After this you can tap on the overflow menu in Detox like this,
await element(by.label('overflowActionButton')).tap();
Thanks to #Leri Gogsadze for pointing me in the right direction

Appcelerator Titanium: How do I change SearchView colors on Android? (hintText and cross icon)

I have a SearchView which is dark and its hinttext and its cross icon are black, so I want to set the color of these two things to white.
I am using a custom theme for Android but it does nothing to the SearchView. This is how my custom theme xml file looks like:
<resources>
<style name="Theme.MyApp" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:spinnerItemStyle">#style/MySpinnerItem</item>
<item name="android:actionBarStyle">#style/SearchViewTheme</item>
</style>
<style name="SearchViewTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:textColorSecondary">#FFFFFF</item>
<item name="android:textColorHint">#CCCCCC</item>
</style>
<style name="MySpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:textSize">14dp</item>
</style>
</resources>
I found a solution. If anyone wants to know what I did:
I just deleted this line:
<item name="android:actionBarStyle">#style/SearchViewTheme</item>
And then, I added this to the .tss file where the SearchView is:
"Window[platform=android]" : {
theme : "SearchViewTheme"
}

React Native ,why can't I align picker item to right in android platform?

I tried to find the solution for ages , but it's still none working! Below is how I wrote:
<View style = {[ {flex: 0.7} ]}>
<Picker
selectedValue={this.state.selectedGender}
onValueChange={this.onValueChange.bind(this, 'selectedGender')}
>
<Item label="Please select gender" value=""/>
<Item label="Male" value="M" />
<Item label="Female" value="F" />
</Picker>
</View>
If you want to change the style of the picker items on Android, you have to change native code.
You'll have to add your style in android/app/src/main/res/values/styles.xml.
To change the picker container
Here I set, the background to null so there is not the down arrow on the left.
<style name="SpinnerStyle" parent="#android:style/Widget.Spinner">>
<item name="android:background">#null</item>
</style>
To change the selected item style
Here I set the items to be centered, the color font to be dark gray and the font size to 16.
<style name="SpinnerItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:gravity">center</item>
<item name="android:textColor">#373737</item>
<item name="android:textSize">16dp</item>
</style>
To change the drapdown items
Just as, the selected item, I want the dropdown items to have the same style.
<style name="SpinnerDropDownItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:gravity">center</item>
<item name="android:textColor">#373737</item>
<item name="android:textSize">16dp</item>
</style>
Finally
Once, you have set your styles for every element of the picker. You have to add the style to the general App theme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:spinnerStyle">#style/SpinnerStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItem</item>
...
</style>
Hope it helps !

How to Stop/Reset AnimationDrawable in Android

Animation drawable is not "stopping".
I want to reset animation drawable when I click on the another button.
Code for starting animation drawable:
MainActivity:
private AnimationDrawable frameAnimation
iconConnecting.setBackgroundResource(R.drawable.frame_animation);
frameAnimation = (AnimationDrawable) iconConnecting.getBackground();
frameAnimation.start();
frame_animation.xml:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="#drawable/connecting0" android:duration="400" />
<item android:drawable="#drawable/connecting1" android:duration="400" />
<item android:drawable="#drawable/connecting2" android:duration="400" />
<item android:drawable="#drawable/connecting3" android:duration="400" />
<item android:drawable="#drawable/connecting4" android:duration="400" />
</animation-list>
In frame_animation.xml, change android:oneshot value to true
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
Documentation of android:oneshot:
"If true, the animation will only run a single time and then stop. If false (the default), it will continually run, restarting at the first frame after the last has finished."