ui-material-components icon indicating copy to clipboard operation
ui-material-components copied to clipboard

show error textfield

Open MariaC15 opened this issue 4 years ago • 13 comments

Make sure to check the demo app(s) for sample usage

Make sure to check the existing issues in this repository

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter.

Which platform(s) does your issue occur on?

  • iOS/Android/Both Both
  • iOS/Android versions 7.1.1/7.0.1
  • emulator or device. What type of device? emulator and device iOS

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it) 7.1.2
  • Cross-platform modules: (check the 'version' attribute in the node_modules/@nativescript/core/package.json file in your project) 7.1.0
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
  • Plugin(s): (look for the version numbers in the package.json file of your project and paste your dependencies and devDependencies here)

I am using the textfield plugin you have created. I want to show the, in android it works by accessing the native view, but in ios I cannot access. android work fine.

`showErrorInput(txtfield: TextField, msj: string, isError:boolean){ if (isAndroid) { const txtfieldAndroid: com.google.android.material.textfield.TextInputLayout = <com.google.android.material.textfield.TextInputLayout>txtfield.android; txtfieldAndroid.setErrorEnabled(isError); txtfieldAndroid.setError(msj); }else if(isIOS){ // PropType,TextFieldProperties,initTextInputEditText

}

}`

MariaC15 avatar Feb 16 '21 13:02 MariaC15

@MariaC15 use the error property instead it will work on both platforms.

farfromrefug avatar Feb 16 '21 13:02 farfromrefug

@farfromrefug When I try to access using MDCTextInputControllerFilled it gives me an error. Cannot find the module. I have uninstalled / installed the plugin but it doesn't work. Installed the types and it doesn't work either. Removing the platforms and neither.

MariaC15 avatar Feb 16 '21 13:02 MariaC15

@MariaC15 dont try to do it natively. simply set the "error" property on your TextField view.

farfromrefug avatar Feb 16 '21 13:02 farfromrefug

@MariaC15 <MDTextField :error="myError" /> this is for Vue

farfromrefug avatar Feb 16 '21 14:02 farfromrefug

@farfromrefug It is possible to do it from angular ts using txtfield.setProperty ("error", "error")?

MariaC15 avatar Feb 16 '21 14:02 MariaC15

@MariaC15 dont know about angular but you need to do it the same way you set any other property.

farfromrefug avatar Feb 16 '21 14:02 farfromrefug

@farfromrefug Ok thanks for your help. It is possible add endiron?

MariaC15 avatar Feb 16 '21 14:02 MariaC15

@farfromrefug add <MDTextField :error="myError" /> When I add a variable to the error this happens Simulator Screen Shot - iPhone 11 Pro Max - 2021-02-16 at 09 11 52

MariaC15 avatar Feb 16 '21 14:02 MariaC15

@MariaC15 this is how it is supposed to work. Following material design

farfromrefug avatar Feb 16 '21 16:02 farfromrefug

@MariaC15 I have the same error.

When using

<MDTextField :error="error" />

with

data: () => ({
  error: 'Email is required'
})

I have this: Capture d’écran 2021-05-20 à 16 32 13

When using

<MDTextField error="error" />

I have this: Capture d’écran 2021-05-20 à 16 32 40

AlbanRicherPro avatar May 20 '21 14:05 AlbanRicherPro

@MariaC15 seems like a timing issue. Always use the first one for now

farfromrefug avatar May 22 '21 09:05 farfromrefug

@farfromrefug I want to use the first proposition, but the rendering is not the same as for the second. Because the message should appear under the textfield (as it is for the second proposition)

AlbanRicherPro avatar May 23 '21 20:05 AlbanRicherPro

@farfromrefug, @MariaC15 I found a solution by setting the helper attribute to ' '

<MDTextField :error="error" helper=" " />

with

data: () => ({
  error: 'Email is required'
})

AlbanRicherPro avatar May 25 '21 09:05 AlbanRicherPro