Skip to content

Commit 08ed2b6

Browse files
committed
Merge pull request #1 from HireAnEsquire/static-display
Static display
2 parents f00317d + bce87c5 commit 08ed2b6

2 files changed

Lines changed: 254 additions & 51 deletions

File tree

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,56 @@ first grid layout example above:
182182

183183
![spinner](https://github.com/insin/newforms-bootstrap/raw/master/spinner.gif "Default async validation spinner")
184184

185+
* `static` - set to `true` to render fields using a static display control: `<p className="form-control-static">{value}</p>`
186+
187+
This is useful if you want to have readonly forms, and switch to editable given a flag:
188+
189+
```html
190+
<BootstrapForm static={!this.props.editable} />
191+
```
192+
193+
Provide a `widgetAttrs.convertStatic` function on a field to convert the value when displaying statically. The following
194+
would render a cost value with a dollar sign in front when `static=true`, but would otherwise just render an integer field:
195+
196+
```javascript
197+
var ProductForm = forms.Form.extend({
198+
cost: forms.IntegerField({
199+
widgetAttrs: {
200+
convertStatic: (value) => '$' + value
201+
}
202+
})
203+
})
204+
```
205+
206+
* `horizontal` - An object for specifying `form-horizontal` classes. Keys are one of the bootstrap
207+
sizes (xs, sm, md, lg), and values are the number given to the form control.
208+
209+
So for example:
210+
211+
```html
212+
<BootstrapForm horizontal={{sm: 10}}/>
213+
```
214+
215+
This would produce fields such as:
216+
217+
```html
218+
<div class="form-group">
219+
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
220+
<div class="col-sm-10">
221+
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
222+
</div>
223+
</div>
224+
<div class="form-group">
225+
<div class="col-sm-offset-2 col-sm-10">
226+
<div class="checkbox">
227+
<label>
228+
<input type="checkbox"> Remember me
229+
</label>
230+
</div>
231+
</div>
232+
</div>
233+
```
234+
185235
### Bootstrap-compatible choice field renderers
186236

187237
The following custom renderers are available for use. Note that the non-inline

0 commit comments

Comments
 (0)