I want to close modal after form submit event is finished. I've done following things:
<form [formGroup]="alertForm" novalidate (ngSubmit)="save(alertForm.value, alertForm.valid)">
<div class="row" style="padding-left: 20px; padding-right: 20px;">
<div class="input-field">
<div class="form-group input-field">
<label for="recipientLogin">Available Recipient</label>
<textarea class="form-control validate" id="recipientLogin" required formControlName="recipientLogin"> </textarea>
</div>
</div>
<div class="input-field">
<div class="form-group input-field">
<select class="form-control" id="alert_level" formControlName="alert_level">
<option value="0" selected> Emergency </option>
<option value="1">Major</option>
<option value="2">Minor</option>
<option value="3">Information</option>
</select>
</div>
</div>
<div class="input-field">
<div class="form-group input-field">
<label for="subject">Subject</label>
<input type="text" class="form-control validate" id="subject" required formControlName="subject">
</div>
</div>
<div class="input-field">
<div class="form-group input-field">
<label for="message">Message</label>
<textarea class="form-control validate" id="message" required formControlName="message"> </textarea>
</div>
</div>
<div class="input-field">
<div class="form-group input-field">
<input type="file" class="form-control" id="media1" />
<input type="file" class="form-control" id="media2" />
<input type="file" class="form-control" id="media3" />
</div>
</div>
</div>
<div>
<div class="col s6">
<div style="padding-left: 20px; padding-right: 20px;">
<button type="submit" class="btn btn-default input-field">Send</button>
</div>
</div>
<div class="col s6 right-align">
<div style="padding-left: 20px; padding-right: 20px;">
<button type="submit" data-dismiss="modal" class="btn btn-default input-field">Close</button>
</div>
</div>
</div>
</form>
This triggers save() on form submit but does not close the modal for that I tried data-dismiss="modal" on save button, which block the save() call and close the modal.
I want to complete save() first after that close modal.
Assuming the form is inside a bootstrap modal, you can use
$('#modalID').modal("hide") to close the modal.
For full reference check here.
Alternatively, on success of your save call you can close the modal via the 'Close' button.
<button #btnId type="submit" />
Which your component can close via this.btnId.click()
Related
Here is the html implementation of the form
div class="container mt-3">
<form #form="ngForm" class="form-inline mb-3"(ngSubmit)="loadMembers()" autocomplete="off">
<div class="form-group">
<label >Age from:</label>
<input type="number" class="form-control ml-1" style="width: 70px;" name="minAge"
[(ngModel)]="userParams.minAge">
</div>
<div class="form-group px-2">
<label >Age to:</label>
<input type="number" class="form-control ml-1" style="width: 70px;" name="maxAge"
[(ngModel)]="userParams.maxAge">
</div>
<div class="form-group px-2">
<label >Show: </label>
<select name="gender" style="width: 130px;" class="form-control ml-1">
<option *ngFor="let gender of genderList" [value]="gender.value">
{{gender.display}}
</option>
</select>
</div>
<button class="btn btn-primary ml-1" type="submit">Apply filters</button>
<button (click)="resetFilters" class="btn btn-info ml-1" type="submit">Reset filters</button>
</form>
And my output on the page is not inline.I just need to know why is my form not displaying inline and a fix if i am missing something
I have some strange thing happening from my self post forms. I thought using form method="post" would not put data in the url. And I'm having different outcomes on both forms
<form method="post" action="" enctype="multipart/form-data" id="testForm">
<div class="form-group">
<div class="panel-heading">
some junk
</div>
<div class="panel-body">
<div class="col-md-12">
<textarea id="summernote" name="Full_Discription" class="form-control" required></textarea>
</div>
<div class="col-md-1">
<input type='hidden' name='var' value='<?php echo "$Known_Issue_id";?>'/>
<button name="submit" type="submit" id="submitButton" class="btn btn-accent">Submit Follow-up</button>
</div>
</div>
</div>
</form>
If I submit this form the hidden data shows in URL but not the body text from summernot
web_known_issues_bug.php?bug=20
<form method="post" enctype="multipart/form-data" id="testForm">
<div class="form-group">
<div class="col-md-2">
<label>Website Issue Type:</label>
<select class="form-control" name="Issue_Plugin" id="Issue_Plugin" required>
<option value="">- Select Web Issue -</option>
</select>
</div>
<div class="col-md-7">
<label>Description Of Known Issue:</label> <input name="Issue_Discription" type="text" value="" class="form-control" required>
</div>
<div class="col-md-2">
<label>Type Of Issue:</label>
<select class="form-control" name="Issue_Type" id="Issue_Type" required>
<option value="">- Bug Type -</option>
</select>
</div>
<div class="col-md-1">
<label>Submit Issue</label><BR>
<input type='hidden' name='bug' value='<?php echo "none";?>'/>
<button name="submit" type="submit" id="submitButton" class="btn btn-accent">Submit Issue</button>
</div>
<div class="col-md-12">
<textarea id="summernote" name="Full_Discription" class="form-control" required><?php echo $SendBody; ?></textarea>
</div>
</div>
This form is spitting everything to the url?
web_known_issues.php?message=Added%20New%20Bug%20List%20Item&title=Siclone%20Crashes%20when%20not%20used%20everyday&full=asdasdasdasdasd
I really need this stuff to send clean urls. Any idea on what I have done wrong?
Sorry, this is solved. My error, I left in some debug code in the miles of PHP
I'm using bootstrap from getbootstrap.com. I want to have a space between the SAVE and CLEAR button. I also want them to align center to be proportioned on the textboxes. How can I achieve that?
<div class="form-group">
<label for="trucktype" class="col-sm-2">Truck Type</label>
<div class="col-sm-4">
<select id="trucktype" name="trucktype" class="form-control" tabindex="2">
<option value="volvo">Service Wheels</option>
<option value="saab">Boom Truck</option>
<option value="mercedes">Crane Truck</option>
<option value="audi">Pole Trailer Truck</option>
</select>
</div>
</div>
<div class="form-group">
<label for="truckloadcapacity" class="col-sm-2">Truck load capacity</label>
<div class="col-sm-4"><input type="text" name="truckloadcapacity" id="truckloadcapacity" class="form-control" tabindex="3"></div>
</div>
<div class="form-group">
<label for="truckdesc" class="col-sm-2">Truck Description:</label>
<div class="col-sm-4"><textarea class="form-control" rows="3" id="truckdesc" tabindex="4"></textarea></div>
</div>
<div class="form-group">
<label for="truckphoto" class="col-sm-2">Truck Photo</label>
<div class="col-sm-4"><input type="file" name="file" id="truckphoto" class="form-control" tabindex="5"></div>
</div>
<!-- BUTTONS start -->
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<input class="btn-primary btn-lg col-sm-4" type="submit" value="Save">
<input type="reset" class="btn-default btn-lg col-sm-4" name="clear" value="Clear">
</div>
</div>
</div>
<!-- BUTTONS end -->
</form>
may be you are looking for this class="text-center" will do a trick, and some CSS for spacing
.btn-spacing
{
margin-right: 5px;
margin-bottom: 5px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="form-group">
<label for="trucktype" class="col-sm-2">Truck Type</label>
<div class="col-sm-4">
<select id="trucktype" name="trucktype" class="form-control" tabindex="2">
<option value="volvo">Service Wheels</option>
<option value="saab">Boom Truck</option>
<option value="mercedes">Crane Truck</option>
<option value="audi">Pole Trailer Truck</option>
</select>
</div>
</div>
<div class="form-group">
<label for="truckloadcapacity" class="col-sm-2">Truck load capacity</label>
<div class="col-sm-4"><input type="text" name="truckloadcapacity" id="truckloadcapacity" class="form-control" tabindex="3"></div>
</div>
<div class="form-group">
<label for="truckdesc" class="col-sm-2">Truck Description:</label>
<div class="col-sm-4"><textarea class="form-control" rows="3" id="truckdesc" tabindex="4"></textarea></div>
</div>
<div class="form-group">
<label for="truckphoto" class="col-sm-2">Truck Photo</label>
<div class="col-sm-4"><input type="file" name="file" id="truckphoto" class="form-control" tabindex="5"></div>
</div>
<!-- BUTTONS start -->
<div class="row">
<div class="col-sm-4">
<div class="form-group btn-block text-center">
<input class="btn-primary btn-lg col-sm-4 btn-spacing " type="submit" value="Save">
<input type="reset" class="btn-default btn-lg btn-spacing col-sm-4" name="clear" value="Clear">
</div>
</div>
</div>
<!-- BUTTONS end -->
For the last form-group class rename it to form-group1 and in the CSS put this. .form-group {text-align:center;}. Also, if you want space between those two buttons, do this. .btn-primary btn-lg col-sm-4 {margin:10px;}
here is an example. jsFiddle
To add space between clear and submit button you can add below CSS.
.form-group .btn-primary {
margin-right:10px;
}
I have a requirement to display Datepicker with Dropdown as a single control, I have tried many samples available on the internet but they do not work for me.
My base code is given below with style in which I have to merge them.
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">Date</label>
<div class="col-sm-4">
<select name="Year" class="form-control" ng-model="Year" required>
<option>2016</option>
<option>2015</option>
<option>2014</option>
</select>
<div ng-messages="form.formValidate.select.$error" ng-if="form.formValidate.$submitted" class="text-danger"><span ng-message="required">This field is required</span></div>
<div class="ui-datepicker shadow-clear">
<p class="input-group">
<input type="text" name="date" required="" class="form-control" />
<span class="input-group-btn">
<button type="button" class="btn btn-default"><em class="ion-calendar"></em></button>
</span>
</p>
<div ng-messages="form.formValidate.date.$error" ng-if="form.formValidate.$submitted" class="text-danger"><span ng-message="required">This field is required</span></div>
</div>
</div>
</div>
</fieldset>
Any kind of help would be appreciated.
Thanks in advance!
Edit
Opps! I missed mentioning that both controls should be side by side as displayed in below image.
Edit2
http://www.bootply.com/Tftcr9VVrH
I wrapped the elements in a div with class="form-inline" and put each group of elements into a div with class="form-group". I forked your bootply here
<fieldset>
<div class="form-inline">
<div class="form-group">
<label for="Year">Date</label>
<select name="Year" class="form-control" required="" ng-model="Year">
<option>2016</option>
<option>2015</option>
<option>2014</option>
</select>
<div class="text-danger" ng-if="form.formValidate.$submitted" ng-messages="form.formValidate.select.$error"><span ng-message="required">This field is required</span></div>
</div>
<div class="form-group">
<div class="ui-datepicker shadow-clear">
<div class="input-group">
<input name="date" class="form-control" required="" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><em class="glyphicon glyphicon-calendar"></em></button>
</span>
</div>
<div class="text-danger" ng-if="form.formValidate.$submitted" ng-messages="form.formValidate.date.$error"><span ng-message="required">This field is required</span></div>
</div>
</div>
I have a form, that I need my save button to be outside of form elements, but if I take it out elsewhere, it doesn`t like refresh the form.
<form ng-submit="save()" action="" name="addInv" novalidate>
<div class="col-md-10">
<label>Name:</label>
<input type="text" ng-model="newlocation.name" class="form-control">
</div>
<div class="col-md-10">
<label>Storage administrator:</label>
<select ng-model="newlocation.administrator" class="form-control" ng-options="user.resource_uri as user.first_name for user in users"></select>
</div>
<div class="col-md-6">
<label>Street:</label>
<input type="text" ng-model="newlocation.street" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>City:</label>
<input type="text" ng-model="newlocation.city" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>Country:</label>
<input type="text" ng-model="newlocation.country" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>Postal code:</label>
<input type="text" ng-model="newlocation.postalCode" class="input-medium form-control">
</div>
<div class="col-md-6">
<button class="btn tbn-lg btn-primary">Save</button>
</div>
</form>
If I put button outside the <form> form doesn't refresh values.
You could use JavaScript to do this
<input type="submit" onclick="document.forms[0].submit();" />