When the user interacts and selects a value in the select, or input of type file, the values of the other fields of the form disappear. Has anyone had this problem? How to solve it? I use the latest version of ionic with react.
show the code that you are using would be helpful in identifying your issue
1 Like
<form className={styles.formulario} onSubmit={(e) => { e.preventDefault(); setDesativado(true)}}>
<IonItem>
<IonLabel>Post type</IonLabel>
<IonSelect value={tipo} okText="Ok" cancelText="Cancel" onIonChange={e => setTipo(e.detail.value)}>
<IonSelectOption value="2">Warning</IonSelectOption>
<IonSelectOption value="3">News</IonSelectOption>
<IonSelectOption value="4">Posts </IonSelectOption> </IonSelect>
</IonItem>
<IonItem>
<IonLabel position='floating'>Title</IonLabel>
<IonInput name="titulo_publicacao" type="text" value="" ></IonInput>
</IonItem>
<IonItem >
<IonTextarea rows={7} value="" className={styles.text_area} name="texto_publicacao" ></IonTextarea>
</IonItem>
<IonItem>
<label htmlFor="arquivo">{arquivo}</label>
<input className="arquivo" type="file" name="arquivo" id="arquivo" onChange={(e) => {
console.log(e);
setArquivo(e.target.value);
}}/>
</IonItem>
<IonButton expand="block" type="submit" disabled={desativado}>Post</IonButton>
</form>
Thanks for your help, but I found the error just now. The solution is to remove value="" from the fields. Starting fields with empty string is not a good idea. It can work with html, but not with react.