This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from RWOverdijk/docs/plenty
Docs/plenty
- Loading branch information
Showing
5 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,48 @@ | ||
# Element sorting | ||
[TBD] | ||
It's possible to change the order in which form elements get rendered by [`<entity-form />`](../component/entity-form.md). The way you'd go about doing this is by using the [`@position()` decorator](../decorators.md#position). | ||
|
||
There's very little to explain on the subject, so here's an example that shows you how to use it. | ||
|
||
## Example | ||
**entity/person.js** | ||
|
||
```js | ||
import {position, inputType} from 'aurelia-form'; | ||
|
||
export class Person { | ||
@position(2) | ||
lastName; | ||
|
||
@position(0) | ||
firstName; | ||
|
||
@position(1) | ||
middleName; | ||
|
||
@position(3) | ||
@inputType('number') | ||
age; | ||
|
||
@position(4) | ||
@inputType('email') | ||
email; | ||
} | ||
``` | ||
|
||
**page/person.js** | ||
|
||
```js | ||
export class SomeViewmodel { | ||
constructor() { | ||
this.person = new Person; | ||
} | ||
} | ||
``` | ||
|
||
**page/person.html** | ||
|
||
```html | ||
<!-- Yes, this renders the entire form. Awesome right!? --> | ||
<entity-form entity.bind="person"> | ||
</entity-form> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Exclude from form | ||
It's possible to exclude some specific properties on an entity from being rendered [`<entity-form />`](../component/entity-form.md). The way you'd go about doing this is by using the [`@noRender()` decorator](../decorators.md#norender). | ||
|
||
There's very little to explain on the subject, so here's an example that shows you how to use it. | ||
|
||
## Example | ||
```js | ||
import {noRender} from 'aurelia-form'; | ||
|
||
export class User { | ||
@type('number') | ||
@noRender() | ||
id; | ||
|
||
username; | ||
|
||
password; | ||
|
||
email; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
# Overriding templates | ||
[TBD] | ||
Aurelia-form uses [aurelia-view-manager](https://aurelia-view-manager.spoonx.org/) to manage views. | ||
This allows us to support multiple css frameworks, and offer the flexibility of supplying your own views. | ||
|
||
## Using aurelia-config | ||
Overwriting templates is pretty simple. Here's an example overwriting the view for `<form-radio />`: | ||
|
||
```js | ||
// Configure function | ||
export function configure(aurelia) { | ||
aurelia.use | ||
.standardConfiguration() | ||
.plugin('aurelia-config', configure => { | ||
return configure([ | ||
'aurelia-form' | ||
// Other plugins | ||
], { | ||
'aurelia-view-manager': { | ||
'spoonx/form': { | ||
map: { | ||
'form-checkbox': 'path/to/your/view.html' | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
``` | ||
|
||
## Using view-manager | ||
If for some reason you wish to use the view-manager directly: | ||
|
||
```js | ||
export function configure(aurelia) { | ||
aurelia.container.get(ViewManager).configureNamespace('spoonx/form', { | ||
map: { | ||
'form-checkbox': 'path/to/your/view.html' | ||
} | ||
}); | ||
} | ||
``` | ||
|
||
## Resources | ||
You can find more information on configuring your views in the [aurelia-view-manager documentation](https://aurelia-view-manager.spoonx.org/configuration.html#). |