Add class if field is already filled VueJS - forms

I am new in Vue and I need to add a new class to div.input-box where inside is label and input.
I can try more options after google but nothing to help me.
html:
<form id="form" class="container">
<div class="row justify-content-center mt-5">
<div class="input-box col-lg-6" #click="isActive = 1" :class="{'focus': isActive === 1}">
<label class="input-label">
{{ $t("system.first_name") }}
</label>
<input type="text" class="input-1" v-model="first_name" #focus="isActive = true" #blur="isActive = false">
</div>
<div class="input-box col-lg-6" #click="isActive = 2" :class="{'focus': isActive === 2}">
<label class="input-label">
{{ $t("system.last_name") }}
</label>
<input type="text" class="input-1" v-model="last_name" #focus="isActive = true" #blur="isActive = false">
</div>
</div>
<div class="row justify-content-center">
<div class="input-box col-lg-12" #click="isActive = 3" :class="{'focus': isActive === 3}">
<label class="input-label">
E-mail
</label>
<input type="text" class="input-1" v-model="email" #focus="isActive = true" #blur="isActive = false">
</div>
</div>
</form>
script:
export default {
name: "RegistrationSecondVersion",
data(){
return {
isActive: false,
first_name: null,
last_name: null,
email: null
}
},
methods: {
checkForInput: function (e) {
let input = e.target;
if (input.value != '') {
input.classList.add('focus');
} else {
input.classList.remove('focus');
}
}
}
}
I had added the function in input but I need after filled to get 'focus' class to div.input-box.
Thank you so much!

You need to call checkForInput function whenever an input occurs. On the other hand, I see no need to use #blur and #focus in your case.
Try this:
<form id="form" class="container">
<div class="row justify-content-center mt-5">
<div class="input-box col-lg-6" #click="isActive = 1" :class="{'focus': isActive === 1}">
<label class="input-label">
{{ $t("system.first_name") }}
</label>
<input type="text" class="input-1" v-model="first_name" #input="checkForInput">
</div>
<div class="input-box col-lg-6" #click="isActive = 2" :class="{'focus': isActive === 2}">
<label class="input-label">
{{ $t("system.last_name") }}
</label>
<input type="text" class="input-1" v-model="last_name" #input="checkForInput">
</div>
</div>
<div class="row justify-content-center">
<div class="input-box col-lg-12" #click="isActive = 3" :class="{'focus': isActive === 3}">
<label class="input-label">
E-mail
</label>
<input type="text" class="input-1" v-model="email" #input="checkForInput">
</div>
</div>
</form>

Related

Default form input value not recognised by form validator in controller

I have a form in which some inputs are disabled but have default values generated and set before the form loads (I can see the default values on the form inputs which are disabled). On form submission, the controller validates the form values before creating an entry in the database. My problem is the disabled inputs with the default values are being seen as blank and I keep getting an error that the input values are requried
HTML
<form enctype="multipart/form-data" method="POST" action="{{ route('admins.store') }}">
#csrf
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label class="bmd-label-floating">Admin Names</label>
<input type="text" name="name" class="form-control {{ $errors->has('name') ? 'error' : '' }}" id="name">
<!-- Error -->
#if ($errors->has('name'))
<div class="error">
{{ $errors->first('name') }}
</div>
#endif
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label class="bmd-label-floating">Admin ID</label>
<input type="text" name="adminID" value="{{ $adminID }}" class="form-control {{ $errors->has('adminID') ? 'error' : '' }}" id="adminID" disabled>
<!-- Error -->
#if ($errors->has('adminID'))
<div class="error">
{{ $errors->first('adminID') }}
</div>
#endif
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="bmd-label-floating">Admin Email</label>
<input type="email" name="email" class="form-control {{ $errors->has('email') ? 'error' : '' }}" id="email">
<!-- Error -->
#if ($errors->has('email'))
<div class="error">
{{ $errors->first('email') }}
</div>
#endif
</div>
</div>
</div>
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label class="bmd-label-floating">Phone Number</label>
<input type="text" name="phonenumber" class="form-control {{ $errors->has('phonenumber') ? 'error' : '' }}" id="phonenumber">
<!-- Error -->
#if ($errors->has('phonenumber'))
<div class="error">
{{ $errors->first('phonenumber') }}
</div>
#endif
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label class="bmd-label-floating">Access Level</label>
<input type="text" name="accessLevel" value="admin" class="form-control {{ $errors->has('accessLevel') ? 'error' : '' }}" id="accessLevel" disabled>
<!-- Error -->
#if ($errors->has('accessLevel'))
<div class="error">
{{ $errors->first('accessLevel') }}
</div>
#endif
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="bmd-label-floating">Password</label>
<input type="text" name="password" value="{{ $password }}" class="form-control {{ $errors->has('accessLevel') ? 'error' : '' }}" id="password" disabled>
<!-- Error -->
#if ($errors->has('password'))
<div class="error">
{{ $errors->first('password') }}
</div>
#endif
</div>
</div>
</div>
<button type="submit" class="btn btn-primary pull-right">Add Admin</button>
<div class="clearfix"></div>
</form>
Controller:
if(Auth::check())
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email',
'phonenumber' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
'adminID'=>'required',
'accessLevel'=>'required',
'password'=>'required'
]);
$admin = Admin::where('email', '=', $request->email)->first();

Error setting form array only brings first value

I can't find the problem to set value in my form. It's only brings me the first value and the mistake is ERROR Error: Cannot find form control at index 1
at FormArray._throwIfControlMissing. Does anyone know what the right way would be like?
in my components
public setValueForm(): void {
const values = {
'_id': this.priceList._id,
'name': this.priceList.name,
'percentage' : this.priceList.percentage,
'allowSpecialRules' : this.priceList.allowSpecialRules,
'rules' : this.priceList.rules || []
};
this.priceListForm.setValue(values);
}
and my html
<div class="row tab-content">
<div formArrayName="rules" *ngFor="let rule of priceListForm.get('rules').controls; let i = index;">
<div [formGroupName]="i">
<div class="row">
<div class="form-group col-md-4">
<label for="category" class="control-label">Rubro:</label>
<select class="form-control" formControlName="category">
<option *ngFor="let category of categories"
[value]="category._id"
[disabled]="readonly">
{{category.description}}
</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="make" class="control-label">Marca</label>
<select class="form-control" formControlName="make">
<option *ngFor="let make of makes"
[value]="make._id"
[disabled]="readonly">
{{make.description}}</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="percentage" class="control-label">Porcentaje:</label>
<div class="input-group">
<input type="number" class="form-control" formControlName="percentage" name="percentage" id="percentage" [readonly]="readonly"/>
</div>
<div *ngIf="formErrors.percentage" class="alert alert-danger">
{{ formErrors.percentage }}
</div>
</div>
<div class="col-md-1">
<label class="control-label">Acción:</label>
<button type="button" class="btn btn-success btn-sm" (click)="addRule()">
<i class="fa fa-plus"></i>
</button>
<button type="button" class="btn btn-danger btn-sm" (click)="deleteRule(i)">
<i class="fa fa-trash-o"></i>
</button>
</div>
</div>
</div>
</div>
</div>
Resolved
let control = <FormArray>this.priceListForm.controls.rules;
this.priceList.rules.forEach(x => {
control.push(this._fb.group({
'_id': x._id,
'percentage': x.percentage,
'make' : x.make,
'category' : x.category
}))
})

I have a nested group Angular form. I want to take the group's controls values and match the name of the controls to my JSON object

I have a small contact form that I have built using Angular. I want to validate the form and change the form data to JSON object.
Here's my Form:
<form [formGroup]="addContactForm" (ngSubmit)="onSubmit()" novalidate >
<div [hidden]="addcontactForm.submitted">
<div class="modal-body" style="overflow: auto">
<!-- create contact -->
<div style="padding: 0 0px 0px 25px;margin-top:30px;">
<div class="form-horizontal">
<span *ngIf="ACname.invalid && (ACname.dirty || ACname.touched)" class="has-error">
<span *ngIf="ACname.errors.required">
Last Name is required.
</span>
</span>
<!-- name -->
<div FormGroupName="ACname">
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACname.addContactFirstName.invalid && (ACname.addContactFirstName.dirty || ACname.addContactFirstName.touched) }">
<label class="col-sm-3" for="addContactFirstName">First Name</label>
<div class="col-sm-7">
<input id="addFirstName"
formControlName="addContactFirstName"
class="form-control"
placeholder="Enter First Name" />
</div>
</div>
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACname.addContactLastName.invalid && (ACname.addContactLastName.dirty || ACname.addContactLastName.touched) }">
<label class="col-sm-3" for="addContactLastName">Last Name</label>
<div class="col-sm-7">
<input id="addLastName"
class="form-control"
formControlName="addContactLastName"
placeholder="Enter Last Name" />
</div>
</div>
</div>
<div FormGroupName="ACcontactMethod">
<!-- office phone -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACcontactMethod.addcontactForm.submitted && !ACcontactMethod.addContactOfficePhone.valid }">
<label class="col-sm-3" for="addContactOfficePhone">Office Phone</label>
<div class="col-sm-7">
<input id="addofcPhone"
type="text"
class="form-control"
formControlName="addContactOfficePhone"
placeholder="Enter Office Number" />
<span *ngIf="addContactOfficePhone.invalid && (addContactOfficePhone.dirty || addContactOfficePhone.touched)" class="has-error">
<span *ngIf="addContactLastName.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- mobile phone -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactMobilePhone.valid }">
<label class="col-sm-3" for="addContactMobilePhone">Mobile Phone</label>
<div class="col-sm-7">
<input id="addmobPhone"
type="text"
class="form-control"
formControlName="addContactMobilePhone"
placeholder="Enter Mobile Number" />
<span *ngIf="addContactMobilePhone.invalid && (addContactMobilePhone.dirty || addContactMobilePhone.touched)" class="has-error">
<span *ngIf="addContactMobilePhone.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- home phone -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactHomePhone.valid }">
<label class="col-sm-3" for="addContactHomePhone">Home Phone</label>
<div class="col-sm-7">
<input id="addhomPhone"
type="text"
class="form-control"
formControlName="addContactHomePhone"
placeholder="Enter Home Number" />
<span *ngIf="addContactHomePhone.invalid && (addContactHomePhone.dirty || addContactHomePhone.touched)" class="has-error">
<span *ngIf="addContactHomePhone.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- email -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactEmail.valid }">
<label class="col-sm-3" for="addContactEmail">Email</label>
<div class="col-sm-7">
<input id="addEmail"
type="email"
class="form-control"
formControlName="addContactEmail"
placeholder="Enter Email" />
<span *ngIf="addContactEmail.invalid && (addContactEmail.dirty || addContactEmail.touched)" class="has-error">
<span *ngIf="addContactEmail.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- chat id -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactChatId.valid }">
<label class="col-sm-3" for="addContactChatId">Chat ID</label>
<div class="col-sm-7">
<input id="addChatID"
type="text"
class="form-control"
formControlName="addContactChatId"
placeholder="Enter Chat ID" />
<span *ngIf="addContactChatId.invalid && (addContactChatId.dirty || addContactChatId.touched)" class="has-error">
<span *ngIf="addContactChatId.errors.required">
Name is required.
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" (click)="addcontactForm.reset()" data-dismiss="modal">Close</button>
<button type="submit"
class="btn btn-primary"
[disabled]="!addcontactForm.valid"
(click)="addContact(model);">
Add Contact
</button>
</div>
</div>
<div class="submitted-message" *ngIf="addcontactForm.submitted">
<p>You've submitted your contact, {{ addcontactForm.value.addContactFirstName }} {{ addcontactForm.value.addContactLastName }}!</p>
<button type="button" class="btn btn-default pull-left" (click)="addcontactForm.reset()" data-dismiss="modal">Close</button>
<button (click)="addcontactForm.resetForm({})">Add new Contact </button>
</div>
</form>
Here's my ts:
import { Component} from '#angular/core';
import { AppComponent } from '../app.component';
import { FormBuilder, Validators, FormGroup, FormControl } from '#angular/forms';
#Component({
selector: 'addcontactmodal',
templateUrl: 'addcontact.component.html'
})
export class AddContactModalComponent {
id: any;
addContactForm: FormGroup;
constructor(private _appComponent: AppComponent, private fb: FormBuilder) {
this.id = localStorage.getItem('Id');
this.addContactForm = this.fb.group({
ACname: new FormGroup({
addContactFirstName: new FormControl('', Validators.minLength(40)),
addContactLastName: new FormControl('', Validators.minLength(40)),
}),
ACcontactMethod: new FormGroup({
addContactOfficePhone: new FormControl('', Validators.minLength(20)),
addContactMobilePhone: new FormControl('', Validators.minLength(20)),
addContactHomePhone: new FormControl('', Validators.minLength(20)),
addContactEmail: new FormControl('', Validators.minLength(127)),
addContactChatId: new FormControl('', Validators.minLength(127))
})
});
}
// private method(s)
private addContact() {
let data = {
ChatId: this.fb.group('addContactChatId').value,
Email: addContactEmail,
FirstName: addContactFirstName,
HomePhone: addContactHomePhone,
MobilePhone: addContactMobilePhone,
LastName: addContactLastName,
OfficePhone: this.model.addContactOfficePhone
}
this._appComponent.signalRService.setAgentContact(this.id, data);
}
}
I want to:
Validate the form
Have the data output to JSON
I do not get any of the validation the form promises. It doesn't submit.
Errors:
nhandled Promise rejection: Cannot read property 'invalid' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'invalid' of undefined
at Object.View_AddContactModalComponent_0.co [as updateDirectives]
You are not using complete property paths for your validation messages. Here's a simplified template of yours:
<form [formGroup]="addContactForm" (ngSubmit)="onSubmit()" novalidate >
<!-- formGroupName - mark all form controls belonging to this group inside tag -->
<div formGroupName="ACname">
<input formControlName="addContactFirstName" />
<!-- use complete property path or do like follows! -->
<span *ngIf="addContactForm.hasError('minlength', 'ACname.addContactFirstName')">
Minlength 40
</span>
</div>
</form>
StackBlitz

Angular FormGroup custom validator not triggered on button click

I am using reactive forms Angular 4 and added a custom validator addressValidation to the form group - addressGroup.
I am updating all fields to mark as touched on submit click. Looks like the custom validator addressValidation doesn't trigger eventhough I marked all fields as touched. I tried marking the formgroup (addressGroup) as touched and dirty on submit but no help.
In general what I am trying to achieve is - By default I want to make street number and Street name required. If po box is entered then street number and Name is not required. Apt # is only required only if street number and name is entered. I am trying to achieve this on the custom validator in the formGroup.
Any idea on what I am doing wrong. Any other alternate way to achieve the above requirement. I am new to Angular and slowly learning the concepts. Any suggestion on How to trigger the custom validator on submit.
buildForm(): void {
this.contactForm = this.fb.group({
emailAddressControl: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
phoneControl: ['', [Validators.required, Validators.minLength(10), Validators.maxLength(10)]],
addressGroup: this.fb.group({
streetNumber: ['', [Validators.maxLength(10)]],
pOBox: ['', [Validators.maxLength(8)]],
aptNumber: ['', [Validators.maxLength(8)]],
streetName: ['', [Validators.maxLength(60)]],
cityControl: ['', [Validators.required, Validators.maxLength(50)]],
stateControl: ['', [Validators.required, Validators.maxLength(2)]],
zipControl: ['', [Validators.required, Validators.maxLength(14)]],
countryControl: ['UNITED STATES OF AMERICA', [Validators.required]],
}, { validator: addressValidation })
})
this.contactForm.valueChanges
.debounceTime(800)
.subscribe(data => this.onValueChanged(data));
this.onValueChanged();
}
onSubmit(): void {
this.markAllFormFieldsAsTouched(this.contactForm);
this.onValueChanged();
}
private markAllFormFieldsAsTouched(formGroup: FormGroup) {
Object.keys(formGroup.controls).forEach(field => {
console.log(field);
const control = formGroup.get(field);
if (control instanceof FormControl) {
control.markAsTouched({ onlySelf: true });
}
else if (control instanceof FormGroup) {
this.markAllFormFieldsAsTouched(control);
control.markAsTouched({ onlySelf: true });
}
else if (control instanceof FormArray) {
for (let formgroupKey in control.controls) {
let formgroup = control.controls[formgroupKey];
if (formgroup instanceof FormGroup) {
this.markAllFormFieldsAsTouched(formgroup);
}
}
}
});
}
function addressValidation(c: AbstractControl): { [key: string]: boolean } | null {
if (c.pristine) {
return null;
}
const pOBoxControl = c.get('pOBox');
const streetNameControl = c.get('streetName');
const streetNumberControl = c.get('streetNumber');
const aptNumberControl = c.get('aptNumber');
if (pOBoxControl.value === null || pOBoxControl.value === "") {
if (streetNumberControl.value === null || streetNumberControl.value === "") {
return { ['streetNumberRequired']: true, ['streetNameRequired']: true };
}
if (streetNameControl.value === null || streetNameControl.value === "") {
return { 'streetNameRequired': true };
}
}
else {
if ((streetNameControl.value === null || streetNameControl.value === "")
&& (streetNameControl.value === null || streetNumberControl.value === "") && aptNumberControl.value !== "") {
return { 'apartmentNumberInvalid': true };
}
}
}
Template
<div class="card">
<div class="card-header bg-info text-white">
<h2>Mailing Address:</h2>
</div>
<div formGroupName="addressGroup" class="card-body">
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label class="form-control-label">PO Box:</label>
<input class="form-control"
[ngClass]="displayFieldCss('pOBox')"
type="text"
formControlName="pOBox"
placeholder=""
maxlength="8" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('pOBox')">
{{validationMessage.pOBox}}
</span>
</div>
</div>
<div class="col-lg-4">
<div class="form-group">
<label class="form-control-label">Street Number:</label>
<input class="form-control"
[ngClass]="displayFieldCss('streetNumber')"
type="text"
formControlName="streetNumber"
placeholder=""
maxlength="10" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('streetNumber')">
{{validationMessage.streetNumber}}
</span>
</div>
</div>
<div class="col-lg-4">
<div class="form-group">
<label class="form-control-label">Apt Number:</label>
<input class="form-control"
[ngClass]="displayFieldCss('aptNumber')"
type="text"
formControlName="aptNumber"
placeholder=""
maxlength="8" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('aptNumber')">
{{validationMessage.aptNumber}}
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label class="form-control-label">Street Name:</label>
<input class="form-control"
[ngClass]="displayFieldCss('streetName')"
type="text"
formControlName="streetName"
placeholder=""
maxlength="60" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('streetName')">
{{validationMessage.streetName}}
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-5">
<div class="form-group">
<label class="form-control-label">City:</label>
<input class="form-control"
[ngClass]="displayFieldCss('cityControl')"
type="text"
formControlName="cityControl"
placeholder="(required)"
maxlength="50" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('cityControl')">
{{validationMessage.cityControl}}
</span>
</div>
</div>
<div class="col-lg-4">
<div class="form-group">
<label class="form-control-label">State/Province (Code):</label>
<input class="form-control"
[ngClass]="displayFieldCss('stateControl')"
type="text"
formControlName="stateControl"
placeholder="(required)"
maxlength="3" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('stateControl')">
{{validationMessage.stateControl}}
</span>
</div>
</div>
<div class="col-lg-3">
<div class="form-group">
<label class="form-control-label">Zip:</label>
<input class="form-control"
[ngClass]="displayFieldCss('zipControl')"
type="text"
formControlName="zipControl"
placeholder="(required)"
maxlength="14" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('zipControl')">
{{validationMessage.zipControl}}
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label class="form-control-label">Country:</label>
<input class="form-control"
[ngClass]="displayFieldCss('countryControl')"
type="text"
formControlName="countryControl"
placeholder="(required)"
maxlength="50" />
<span class="invalid-feedback" *ngIf="isValidToDisplayErrors('countryControl')">
{{validationMessage.countryControl}}
</span>
</div>
</div>
</div>
</div>
</div>
You must use control.updateValueAndValidity() like this
onSubmit(): void {
if (this.form.valid) {
} else {
this.validateAllFormFields(this.committeForm);
this.logValidationErrors(this.committeForm);
this.scrollToError();
}
}
validateAllFormFields(formGroup: FormGroup) {
Object.keys(formGroup.controls).forEach(field => {
const control = formGroup.get(field);
if (control instanceof FormControl) {
control.updateValueAndValidity()
} else if (control instanceof FormGroup) {
this.validateAllFormFields(control);
}
});
}

Angular refresh page after disable DOM field form

I click Buy radio button, images upload field will be removed, but when i click submit, the page refresh. It works normally when I don't affect DOM
Please, explain me what happened ?
Here is my code
onSubmitPost() {
this.progress = true;
const fileList: FileList = this.event.target.files;
if (fileList.length > 0) {
const fileListLength = fileList.length;
const formData: FormData = new FormData();
formData.append('title', this.title);
formData.append('telephone', this.telephone);
formData.append('description', this.description);
formData.append('city', this.city);
if (this.isSell === true) {
for (let x = 0; x < fileListLength; x++) {
formData.append('thumbnail', fileList[x]);
}
}
const headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Authorization', 'clientId 7702919f7e72965');
this.http
.post('http://localhost:3000/api/post', formData, {
headers: headers
})
.map(res => res.json())
.subscribe(
data => {
this.Notificationervice.success('Success');
this.progress = false;
},
error => this.Notificationervice.error('Something wrong')
);
}
}
}
HTML Code
<div id="new-post" class="modal" materialize="modal">
<div class="modal-content">
<div class="row">
<form class="col s12" (submit)="onSubmitPost()" enctype="multipart/form-data">
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">web</i>
<input id="icon_prefix" type="text" class="validate" name="title" [(ngModel)]="title">
<label for="icon_prefix">Title</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">phone</i>
<input id="icon_telephone" type="tel" class="validate" name="telephone" [(ngModel)]="telephone">
<label for="icon_telephone">Telephone</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">mode_edit</i>
<textarea id="icon_prefix2" class="materialize-textarea" [(ngModel)]="description" name="description"></textarea>
<label for="icon_prefix2">Description</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">location_on</i>
<input type="text" id="autocomplete-input" class="autocomplete" materialize="autocomplete" [materializeParams]="[{'data': {'houston': null, 'Cali': null}}]"
[(ngModel)]="city" name="city">
<label for="autocomplete-input">City</label>
</div>
</div>
<div class="row">
<div class="col s6">
<p>
<input name="isSell" type="radio" id="buy" (change)="isSell = !isSell" [checked]="!isSell" />
<label for="buy">Buy</label>
</p>
</div>
<div class="col s6">
<p>
<input name="isSell" type="radio" id="sell" (change)="isSell = !isSell" [checked]="isSell" />
<label for="sell">Sell</label>
</p>
</div>
</div>
<div class="file-field input-field" *ngIf="isSell">
<div class="btn">
<span>Images</span>
<input type="file" multiple accept='image/*' name="post" (change)="onChange($event)">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Upload one or more files">
</div>
</div>
<div class="modal-footer">
<input type="submit" class="modal-action modal-close waves-effect waves-green btn-flat" value="Submit">
</div>
</form>
</div>
</div>
</div>