This repository has been archived by the owner on May 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not rendered: frontile forms ChangesetForm
- Loading branch information
1 parent
a8f6c18
commit 61ad013
Showing
2 changed files
with
40 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
{{#if @model}} | ||
<div class="form-horizontal"> | ||
<div class="form-group"> | ||
<label class="col-sm-2 control-label"> | ||
Nome: | ||
</label> | ||
<div class="col-sm-6"> | ||
<Input @type="text" @value={{@model.nome}} class="form-control" placeholder="Centro custo" autofocus/> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-sm-2 control-label"> | ||
Versão: | ||
</label> | ||
<div class="col-sm-6"> | ||
<Input @type="text" @value={{@model.version}} class="form-control" placeholder="Versão" autofocus/> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-offset-2 col-sm-10"> | ||
<button type="submit" class="btn btn-success" {{on "click" (fn this.save @model)}}> | ||
Salvar | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
{{else}} | ||
Regsitro não Encontrado | ||
{{/if}} | ||
{{#let (changeset this.myFormModel this.myValidations) as |changesetObject|}} | ||
<ChangesetForm @changeset={{changesetObject}} as |Form changeset|> | ||
<Form.Input @fieldName="name.first" @label="First Name" /> | ||
<Form.Input @fieldName="name.last" @label="Last Name" /> | ||
<Form.Input @fieldName="email" @label="Email" /> | ||
<Form.Input @fieldName="hometown" @label="Home Town" /> | ||
<Form.Select @fieldName="preferences" @label="Preferences" /> | ||
|
||
<button type="submit"> | ||
Submit | ||
</button> | ||
</ChangesetForm> | ||
{{/let}} |
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,11 +1,38 @@ | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import DefaultComponent from '../default/default'; | ||
import { Changeset } from 'ember-changeset'; | ||
import lookupValidator from 'ember-changeset-validations'; | ||
import validatePresence from 'ember-changeset-validations/validators/presence'; | ||
|
||
export default class CentroCustosFormComponent extends DefaultComponent { | ||
@tracked redirectTo = '/centro_custos'; | ||
@tracked modelString = 'centro_custo'; | ||
|
||
myFormModel = { | ||
name: { | ||
first: 'Ron', | ||
last: 'Swanson' | ||
}, | ||
email: '[email protected]', | ||
hometown: 'Pawnee, IN', | ||
preferences: ['Lagavulin', 'Steak', 'Bacon', 'No govt.'] | ||
}; | ||
|
||
validations = { | ||
myValue: validatePresence(true) | ||
}; | ||
|
||
myModel = { | ||
myValue: '' | ||
}; | ||
|
||
myChangeset = new Changeset( | ||
this.myModel, | ||
lookupValidator(this.validations), | ||
this.validations | ||
); | ||
|
||
@action | ||
save(model, ...event) { | ||
super.save(model, ...event); | ||
|