I am working on an Angular 7 application using PrimeNG and Primeflex. While trying to style a form based component, I have trouble with <input pInputText ...> elements not respecting the prime-flex styling (or at least not behaving as I would expect).
Summary of issue
(Variant 1)
I am enclosing both a <label> and <input> element in two nested <div> elements which are styled with class="p-grid" and class="p-col-*".
<div class="p-grid">
<div class="p-col-8">
<label for="description">Description</label><br/>
<input id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label for="numeric">Numeric</label><br/>
<input id="numeric" pInputText formControlName="numeric">
</div>
</div>
I was expecting the <input> field to grow/shrink with the available space, but it seems to have a fixed width that does not adjust to the available space or the number of columns I am using.
(Variant 2)
I then tried nesting another p-gridelement within the column-div and giving each element the full width:
<div class="p-grid">
<div class="p-col-8">
<div class="p-grid">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
</div>
<div class="p-col-4">
<div class="p-grid">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
</div>
This does indeed make the <input> field grow to use the available outer column space, but somehow destroys the margin between the columns/fields.
(Variant 3)
After some experimenting I have come up with a solution that does what I want, but it uses incorrect nesting of prime flex classes:
<div class="p-grid">
<div class="p-col-8">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
This lets the fields grow/shrink in size according to the outer column configuration and maintains the margin between fields/columns. However, as this seems to violate the nesting rules of primeflex as I understood them, I am uncertain if this is indeed the correct way to do this.
Detailed working example showing the problem
The working example can also be found on stackblitz.
Here is a complete working example, based on a default angular project (created with ng new demo):
Modifications to dependencies in package.json
(npm i --save primeflex primeicons primeng)
"primeflex": "^1.0.0-rc.1",
"primeicons": "^1.0.0",
"primeng": "^8.0.0-rc.1"
Modifications to angular.json
"styles": [
'node_modules/primeicons/primeicons.css',
'node_modules/primeng/resources/primeng.min.css',
'node_modules/primeflex/primeflex.css',
'node_modules/primeng/resources/themes/nova-light/theme.css',
"src/styles.css"
],
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import {FormsModule, ReactiveFormsModule} from '#angular/forms';
import {PanelModule} from 'primeng/panel';
import {AutoCompleteModule} from 'primeng/autocomplete';
import {BrowserAnimationsModule} from '#angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { ListComponent } from './list.component';
import { DetailComponent } from './detail.component';
import { LeftComponent } from './left.component';
import { RightComponent } from './right.component';
#NgModule({
declarations: [
AppComponent,
ListComponent,
DetailComponent,
LeftComponent,
RightComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
PanelModule,
AutoCompleteModule,
FormsModule,
ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-root',
template: `
<ng-container>
<h3>Title</h3>
<div class="container">
<app-list></app-list>
<app-detail></app-detail>
</div>
</ng-container>`,
styles: [`
div.container {
display: flex;
flex-wrap: nowrap;
}
app-list {
flex: 0 0 auto;
}
app-detail {
flex: 1 0 auto;
}`
]
})
export class AppComponent {
title = 'demo';
}
list.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-list',
template: `
<p-panel [header]="'List'">
<div class="item" *ngFor="let item of items">
<div>{{item}}</div>
</div>
</p-panel>`
})
export class ListComponent {
items: string[] = ['Item 1', 'Item 2', 'Item 3'];
}
detail.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-detail',
template: `
<div class="left">
<p-panel [header]="'Left'">
<app-left></app-left>
</p-panel>
</div>
<app-right></app-right>`,
styles: [':host { display: flex; } div.left{ flex: 1 0 auto; padding: 0 15px; } app-right { flex: 0 1 50%; }']
})
export class DetailComponent {
}
left.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-left',
template: '<p>left works!</p>'
})
export class LeftComponent {
}
right.component.ts
(Choose which version of right*.component.html by uncommenting the correct lines. The order of these correspond to the order I used to present my three approaches above)
import { Component, OnInit } from '#angular/core';
import {FormBuilder, FormGroup} from '#angular/forms';
#Component({
selector: 'app-right',
// --> choose variant by activating one of the three following lines
templateUrl: './right1.component.html'
// templateUrl: './right2.component.html'
// templateUrl: './right3.component.html'
})
export class RightComponent implements OnInit {
form: FormGroup;
items: string[] = ['Austria','France','Germany','Italy','Liechtenstein','Switzerland'];
constructor(private fb: FormBuilder) { }
ngOnInit() {
this.form = this.buildForm();
this.fillForm();
}
buildForm(): FormGroup {
return this.fb.group({
id1: [{value: '', disabled: true}],
id2: [{value: '', disabled: true}],
id3: [{value: '', disabled: true}],
auto: [{value: '', disabled: true}],
description: [{value: '', disabled: true}],
numeric: [{value: '', disabled: true}],
field1: [{value: '', disabled: true}],
field2: [{value: '', disabled: true}],
field3: [{value: '', disabled: true}],
field4: [{value: '', disabled: true}]
});
}
fillForm() {
this.form.controls.id1.setValue('42');
this.form.controls.id2.setValue('666');
this.form.controls.id3.setValue('314152');
this.form.controls.auto.setValue('Germany');
this.form.controls.description.setValue('Short text');
this.form.controls.numeric.setValue('2345');
this.form.controls.field1.setValue('foo');
this.form.controls.field2.setValue('bar');
this.form.controls.field3.setValue('baz');
this.form.controls.field4.setValue('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
}
}
right1.component.html (Variant 1)
<p-panel [header]="'Right 1'">
<form [formGroup]="form" class="container">
<div class="p-grid">
<div class="p-col-12">
<label for="id">ID</label>
<div>
<input pInputText id="id" formControlName="id1">
<input pInputText formControlName="id2">
<input pInputText formControlName="id3">
</div>
</div>
</div>
<h3>Grouped Information</h3>
<div class="p-grid">
<div class="p-col-12">
<label for="auto">Autocomplete</label>
<p-autoComplete
id="auto"
formControlName="auto"
[suggestions]="items"
[style]="{width: '100%'}">
</p-autoComplete>
</div>
</div>
<div class="p-grid">
<div class="p-col-8">
<label for="description">Description</label><br/>
<input id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label for="numeric">Numeric</label><br/>
<input id="numeric" pInputText formControlName="numeric">
</div>
</div>
<h3>More grouped information</h3>
<div class="p-grid">
<div class="p-col-3">
<label for="field1">Field 1</label><br/>
<input id="field1" pInputText formControlName="field1">
</div>
<div class="p-col-3">
<label for="field2">Field 2</label><br/>
<input id="field2" pInputText formControlName="field2">
</div>
<div class="p-col-3">
<label for="field3">Field 3</label><br/>
<input id="field3" pInputText formControlName="field3">
</div>
<div class="p-col-3">
<label for="field4">Field 4</label><br/>
<input id="field4" pInputText formControlName="field4">
</div>
</div>
</form>
</p-panel>
right2.component.html (Variant 2)
<p-panel [header]="'Right 2'">
<form [formGroup]="form" class="container">
<div class="p-grid">
<div class="p-col-12">
<label for="id">ID</label>
<div>
<input pInputText id="id" formControlName="id1">
<input pInputText formControlName="id2">
<input pInputText formControlName="id3">
</div>
</div>
</div>
<h3>Grouped Information</h3>
<div class="p-grid">
<div class="p-col-12">
<label for="auto">Autocomplete</label>
<p-autoComplete
id="auto"
formControlName="auto"
[suggestions]="items"
[style]="{width: '100%'}">
</p-autoComplete>
</div>
</div>
<div class="p-grid">
<div class="p-col-8">
<div class="p-grid">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
</div>
<div class="p-col-4">
<div class="p-grid">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
</div>
<h3>More grouped information</h3>
<div class="p-grid">
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field1">Field 1</label>
<input class="p-col-12" id="field1" pInputText formControlName="field1">
</div>
</div>
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field2">Field 2</label>
<input class="p-col-12" id="field2" pInputText formControlName="field2">
</div>
</div>
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field3">Field 3</label>
<input class="p-col-12" id="field3" pInputText formControlName="field3">
</div>
</div>
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field4">Field 4</label>
<input class="p-col-12" id="field4" pInputText formControlName="field4">
</div>
</div>
</div>
</form>
</p-panel>
right3.component.html (Variant 3)
<p-panel [header]="'Right 3'">
<form [formGroup]="form" class="container">
<div class="p-grid">
<div class="p-col-12">
<label for="id">ID</label>
<div>
<input pInputText id="id" formControlName="id1">
<input pInputText formControlName="id2">
<input pInputText formControlName="id3">
</div>
</div>
</div>
<h3>Grouped Information</h3>
<div class="p-grid">
<div class="p-col-12">
<label for="auto">Autocomplete</label>
<p-autoComplete
id="auto"
formControlName="auto"
[suggestions]="items"
[style]="{width: '100%'}">
</p-autoComplete>
</div>
</div>
<div class="p-grid">
<div class="p-col-8">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
<h3>More grouped information</h3>
<div class="p-grid">
<div class="p-col-3">
<label class="p-col-12" for="field1">Field 1</label>
<input class="p-col-12" id="field1" pInputText formControlName="field1">
</div>
<div class="p-col-3">
<label class="p-col-12" for="field2">Field 2</label>
<input class="p-col-12" id="field2" pInputText formControlName="field2">
</div>
<div class="p-col-3">
<label class="p-col-12" for="field3">Field 3</label>
<input class="p-col-12" id="field3" pInputText formControlName="field3">
</div>
<div class="p-col-3">
<label class="p-col-12" for="field4">Field 4</label>
<input class="p-col-12" id="field4" pInputText formControlName="field4">
</div>
</div>
</form>
</p-panel>
Screenshots illustrating the issue
Variant 1 (not growing/shrinking)
Variant 2 (growing/shrinking but missing margins)
Variant 3 (working but invalid nesting)
Add
style="width: 100%;"
To your inputs in right1.component.html (or define/use a class with width of 100%), for example:
<input id="description" style="width: 100%;" pInputText formControlName="description">
An input by default is size=20, and is not going to take up the width of the div. The p-col div is growing appropriately, just not the input inside it.
Related
I'm having this problem with Bootstrap inputs when a record is called for edition:
My code to define inputs:
<div class="card card-frame">
<div class="card-body">
<div class="container">
<div class="row fieldcontain ${hasErrors(bean: materialInstance, field: 'nombre', 'error')} required">
<div class="col">
<div class="input-group input-group-outline my-1">
<label class="form-label"><g:message code="material.nombre.label" default="Nombre" /></label>
<input class="form-control" name="nombre" required="" value="${materialInstance?.nombre}">
</div>
</div>
</div>
<hr>
<div class="row fieldcontain ${hasErrors(bean: materialInstance, field: 'cantidadMinima1', 'error')} required">
<div class="col">
<div class="input-group input-group-outline my-1">
<label class="form-label"><g:message code="material.cantidadMinima1.label" default="Nombre" /></label>
<input class="form-control" name="cantidadMinima1" required="" value="${materialInstance?.cantidadMinima1}">
</div>
</div>
</div>
...
...
</div>
</div>
I've googled and found there's a class called is-filled but when applied nothing changes. Am I missing something to have inputs like this?
I'm using this Bootstrap-based components: https://www.creative-tim.com/learning-lab/bootstrap/forms/material-dashboard
While making a form on react I downloaded some libraries and copied some example I ultimately went with one I made my self but now my entire project has this validation that will stay no matter what I put in the project. Every time I click a button I get a tooltip and I have no idea how to control it.
Here is my code
import React, { useEffect } from 'react';
import axios from 'axios'
const FormRequest = () => {
const formSubmitHandler = () => {
console.log()
}
return (
<div >
<div >
<div >
<div>
<div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div >
<div >
<div >
<span>CONTACT</span>
<span>US</span>
</div>
</div>
<div >
<form onSubmit={(formSubmitHandler)}>
<div >
<input
placeholder="NAME"
name="name"
onChange={''} value={''} required />
</div>
<div >
<input
type="email"
onChange={''} value={''}
placeholder="EMAIL"
name="email"
required />
</div>
<div >
<input
placeholder="CONTACT NO"
name="contact"
onChange={''} value={''}
/>
</div>
<div >
<select
placeholder="REASON"
name="reasonForContact"
onChange={''} value={'onForContact'}
defaultValue="">
<option disabled={true} value="">Reason for Contact</option>
<option value="">apple</option>
<option value="">coconut</option>
<option selected value="coconut">cocnutn</option>
<option value="mango">Mango</option>
</select>
</div>
<div app-form-group >
<input placeholder="MESSAGE"
name="message"
onChange={''} value={''} required
/>
</div>
<div >
<div >
<input
type="checkbox"
checked={ ''}
onChange={''} value={''}
name="acceptTerms"
required />
<p> Do you agree to us saving your details for future us?</p>
</div>
</div>
<div >
<button >CANCEL</button>
<button >SEND</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>)
};
export default FormRequest;
Here is the output
Remove the "required" keyword from your input fields
The required attribute is the HTML attribute, to have the form validation for inputs like phone number, email and so on. You should know about this.
This is the output of my code:
I want the "welcome to the site" to be displayed at center of the page, how do i do this?
This is the code of app.component.html here I haved {{title}} templated which will be displayed at the top of the page.
<h4>{{title}}</h4>
<div class="col-sm-10">
<button type="button" class="btn btn-default" (click)="createEmp()">Create Employee</button>
</div>
<div style="margin-top: 60px;">
<div class = "container">
<div *ngIf="add">
<h2>Add Employee:</h2>
<form class="form-horizontal" #empForm="ngForm">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" minlength="4" [(ngModel)]="model.name" placeholder="Enter Your Name" #name="ngModel" required/>
<div *ngIf="name.invalid && (name.dirty || name.touched)" class="alert alert-danger">
<div *ngIf="name.errors.required">
Name is required.
</div>
<div *ngIf="name.errors.minlength">
Name must be at least 4 characters long.
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="position">Position:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="position" [(ngModel)]="model.position" placeholder="Enter your position" required />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="salary">Salary:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="salary" [(ngModel)]="model.salary" placeholder="Enter Salary" required />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default" (click)="addEmployee()" [disabled]="empForm.invalid">Add Employee</button>
</div>
</div>
</form>
</div>
<div *ngIf="edit">
<h2>Update Employee:</h2>
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name"
name="name" [(ngModel)]="model2.name" placeholder="Enter Your Name" #name="ngModel" required/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="position">Position:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="position" name="position" [(ngModel)]="model2.position" placeholder="Enter your position" required/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="salary">Salary:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="salary" name="salary" [(ngModel)]="model2.salary" placeholder="Enter Salary" required/>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default" (click)="updateEmployee()">update Employee</button>
</div>
</div>
</form>
</div>
<div *ngIf="Show">
<h2>Employee Details</h2>
<table class="table table-bordered">
<thead>
<tr>
<th width=400>Name</th>
<th width=400>Position</th>
<th width=200>Salary</th>
<th width=400>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let employee of employees; let i=index">
<td>{{employee.name}}</td>
<td>{{employee.position}}</td>
<td>{{employee.salary}}</td>
<td>
<a class="btn btn-success" (click)="editEmployee(i)">Edit</a>
<a class="btn btn-danger" (click)="deleteEmployee(i)">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
this is the ts file where i added title name here
import {Component, OnInit} from '#angular/core';
import { FormControl, FormGroup , Validators} from '#angular/forms';
import { FormsModule, ReactiveFormsModule } from '#angular/forms';
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
model:any={};
model2:any={};
edit= false;
add=false;
create=true;
Show=false;
myValue;
ngOnInit(){
this.model = new FormGroup({
'name': new FormControl(this.model.name, [
Validators.required,
Validators.minLength(4),
]),
'position': new FormControl(this.model.position),
'salary': new FormControl(this.model.salary, Validators.required)
});
}
title = 'Welcome to the Site';
employees = [{name :"Sunil", position : "Developer", salary : 20000},
{name :"Vamshi", position : "Java Developer", salary : 30000},
{name : "Chethan", position : ".Net Developer", salary : 10000}];
createEmp(){
this.add=true;
this.create=false;
this.Show=false;
this.edit=false;
}
addEmployee()
{
console.log()
this.employees.push(this.model);
this.Show = true;
this.add=false;
this.model = {};
}
deleteEmployee(i){
this.employees.splice(i,1)
this.Show=true;
console.log(i);
}
editEmployee(k){
this.edit = true;
this.Show=false;
this.add=false;
this.model2.name = this.employees[k].name;
this.model2.position = this.employees[k].position;
this.model2.salary = this.employees[k].salary;
this.myValue = k;
}
updateEmployee(){
this.Show=true;
this.edit = false;
let k = this.myValue;
for(let i=0;i<this.employees.length;i++){
if(i==k)
{
this.employees[i]= this.model2;
this.model2 = {};
}
}
}
}
The title must be displayed center at all of the pages tag is not helping for me. Is there another way to do this?
You just need to use the align:center; css for your <h4> tag that has the title value:
h4 {
text-align: center;
}
i am trying nested component in angular 2 where we add dynamically component on click multiple time but the problem is when we click on check box of second component it always trigger the first component checkbox..my code in html is follow how to solve the issue the other controls are work fine...
<div [formGroup]="itemForm" class="row order-persons-row">
<div class="small-12 columns">
<div class="order-item">
<div class="row order-persons-row align-stretch">
<div class="small-12 medium-6 columns">
<div class="order-item-col-top">
<div>Diagnosis (ICD10) *</div>
<div>
<select formControlName="icd9" name="icd9">
<option value="">Select Diagnosis</option>
<option value="husker">Husker</option>
<option value="starbuck">Starbuck</option>
<option value="hotdog">Hot Dog</option>
<option value="apollo">Apollo</option>
</select>
<control-messages [control]="itemForm.controls.icd9" [name]="'Diagnosis'"></control-messages>
</div>
<div class="order-item-sep"></div>
<div>Item-HCPC *</div>
<div>
<select formControlName="hcpcs" name="hcpcs">
<option value="">Select Item-Hcpc</option>
<option value="husker">Husker</option>
<option value="starbuck">Starbuck</option>
<option value="hotdog">Hot Dog</option>
<option value="apollo">Apollo</option>
</select>
<control-messages [control]="itemForm.controls.hcpcs" [name]="'Hcpc'"></control-messages>
</div>
</div>
</div>
<div class="small-12 medium-6 columns">
<div class="order-item-col-top">
<div>Justification</div>
<div><input type="text" formControlName="justification" name="justification" class="" placeholder="Justification"/></div>
<control-messages [control]="itemForm.controls.justification" [name]="'justification'"></control-messages>
<div class="order-item-sep"></div>
<div class="flex-container align-justify"><span>Quantity *</span></div>
<div class="flex-container align-justify"><input type="number" formControlName="quantityFrequence" class="" placeholder="Quantity"/></div>
<control-messages [control]="itemForm.controls.quantityFrequence" [name]="'Quantity'"></control-messages>
</div>
</div>
</div>
<div class="row order-persons-row align-stretch">
<div class="small-12 medium-6 columns">
<div class="order-item-col-bottom order-docs">
<div class="order-item-sep"></div>
<div class="flex-container align-justify">
<span>Prior authorization required?</span>
<span><div class="switch tiny">
<input class="switch-input" id="priorAuthRequired" formControlName="priorAuthRequired" type="checkbox" name="priorAuthRequired" checked>
<label class="switch-paddle" for="priorAuthRequired">
<span class="show-for-sr">Tiny Sandwiches Enabled</span>
</label>
</div>
</span>
</div>
<div class="flex-container align-justify">
<span>Beyond quantity limit?</span>
<span><div class="switch tiny">
<input class="switch-input" formControlName="beyondQtyLimit" id="beyondQtyLimit[]" type="checkbox" name="beyondQtyLimitName">
<label class="switch-paddle" for="beyondQtyLimit[]">
<span class="show-for-sr">Tiny Sandwiches Enabled</span>
</label>
</div>
</span>
<control-messages [control]="itemForm.controls.beyondQtyLimit" [name]="'Quantity'"></control-messages>
</div>
<div class="flex-container align-justify">
<div class="form-warning is-visible">
Additional documentation must be provided to support determination of medical necessity.
</div>
</div>
<div class="flex-container align-justify">
<span>Custom item?</span>
<span><div class="switch tiny">
<input class="switch-input" formControlName="customItem" id="customItem" type="checkbox" name="customItemName">
<label class="switch-paddle" for="customItem">
<span class="show-for-sr">Tiny Sandwiches Enabled</span>
</label>
</div>
</span>
</div>
<div class="flex-container align-justify">
<div class="form-warning is-visible">
Additional documentation must be provided to support determination of medical necessity.
</div>
</div>
</div>
</div>
<div class="small-12 medium-6 columns">
<div class="order-item-col-bottom order-docs">
<div class="order-item-sep"></div>
<div>Attachments<span class="button-span"><button type="button" class="button order-doc-button">Add New</button></span></div>
<ul>
<li class="order-doc"> DocumentName.pdf <span class="button-span"><button type="button" class="button order-doc-button">View</button></span><span class="button-span"><button type="button" class="button order-doc-button">Remove</button></span></li>
<li class="order-doc"> Document2222Name.pdf <span class="button-span"><button type="button" class="button order-doc-button">View</button></span><span class="button-span"><button type="button" class="button order-doc-button">Remove</button></span></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
here is component
#Component({
moduleId: module.id,
selector: 'Orders-order',
templateUrl: 'order.component.html',
styleUrls: ['order.component.css']
})
export class OrderComponent implements OnInit {
id: any;
subscription: any;
selectedVendor: Vendor;
order: Order;
managerList:any;
mylist:any;
item:number;
orderForm: FormGroup;
customDetails:FormGroup;
isCCP:boolean=true;
isXIX:boolean=false;
toDay:string;
nextDay:string;
nextDate:string;
initial:boolean=true;
revision:boolean=true;
recertification:boolean=true;
init:any;
constructor(private errorService: ErrorService,
private router: Router, private _route: ActivatedRoute,
private fb: FormBuilder, private orderService: OrderService) {
}
ngOnInit() {
this.typeXIX();
}
initItem1() {
return this.fb.group({
hcpcs: ['', Validators.required],
quantityFrequence: ['',Validators.required],
icd9:['',Validators.required],
justification:['',],
beyondQtyLimit:['',],
customItem:['',],
priorAuthRequired:['',]
});
}
typeXIX(){
this.isCCP=false;
this.isXIX=true;
if(this.isXIX) {
this.orderForm = this.fb.group({
entity: [''],
coordinator: this.fb.group({
id: ['', Validators.required]
}),
patient: this.fb.group({
id: ['', Validators.required]
}),
hsp: this.fb.group({
id: ['', Validators.required]
}),
vendor: this.fb.group({
id: ['', Validators.required]
}),
providerGroup:this.fb.group({
id:['',Validators.required]
}),
customDetails: this.fb.group({
extraInformation: ['',],
lines: this.fb.array([
this.initItem1(),
]),
durationNeed: ['',],
durationSupply: ['',],
lastSeenPhysician: ['', Validators.required]
}),
});
}
}
addItemXIX() {
const control = <FormArray>this.orderForm.controls['customDetails'].get('lines');
control.push(this.initItem1());
}
removeItemXIX(i: number) {
const control = <FormArray>this.orderForm.controls['customDetails'].get('lines');
control.removeAt(i);
}
}
I am trying to align textfields with bootstrap however I keep failing to adopt anything I found on sources to my project. What I am trying to do is aligning e-mail and password text-fields but leave 'Remember me' and 'Login' centered.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<form method="POST" action="/auth/login">
<div class="form-group">
<div>
<label for="exampleInputEmail1">Email address</label>
<input type="email" name="email" value="{{ old('email') }}">
</div>
</div>
<div class="form-group">
<div>
<label for="exampleInputPassword1">Password</label>
<input type="password" name="password" id="password">
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember me
</label>
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-default">Login</button>
</div>
</div>
</form>
You can use Bootstrap's form-horizontal class to help achieve the layout.
Demo: http://www.bootply.com/nJ2P2gi76B
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Log in</button>
</div>
</div>
</form>
You can access only the text input by using a css attribute selector.
For Example...
input[type="text"] {
...
}
You can get more specific if needed...
#someID input[type="text"] {
...
}
you can use text-center to center the inner content of your div. you can use text-left, text-center, text-right classes to align the contents.
#import url(https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css);
#import url(https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css);
<form method="POST" action="/auth/login">
<div class="form-group">
<div>
<label for="exampleInputEmail1">Email address</label>
<input type="email" name="email" value="{{ old('email') }}">
</div>
</div>
<div class="form-group">
<div>
<label for="exampleInputPassword1">Password</label>
<input type="password" name="password" id="password">
</div>
</div>
<div class="form-group text-center">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember me
</label>
</div>
</div>
<div class="form-group text-center">
<div>
<button type="submit" class="btn btn-default">Login</button>
</div>
</div>
</form>
It would help if you could post a JSFiddle with the css you are using!
Guessing from what i see:
You could add a class to both fields and override the css.
or put both fields in a div and align them without impacting the rest.
Using an enclosing div:
JSFiddle
CSS:
.input-fields {
width: 300px;
}
.input-fields .form-group {
float: right;
}
.form-group {
clear: both;
text-align: center;
}
HTML:
<form method="POST" action="/auth/login">
<div class="input-fields">
<div class="form-group">
<div>
<label for="exampleInputEmail1">Email address</label>
<input type="email" name="email" value="{{ old('email') }}">
</div>
</div>
<div class="form-group">
<div>
<label for="exampleInputPassword1">Password</label>
<input type="password" name="password" id="password">
</div>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember me
</label>
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-default">Login</button>
</div>
</div>
</form>