Skip to content

Instantly share code, notes, and snippets.

@stephencarr
Created December 30, 2016 01:56
Show Gist options
  • Save stephencarr/53c8c0e11f326de432cc543f69c12f4e to your computer and use it in GitHub Desktop.
Save stephencarr/53c8c0e11f326de432cc543f69c12f4e to your computer and use it in GitHub Desktop.
<div class="form-wrap">
{{#bs-form class="label-mb-10" formLayout=vertical model=user action="submit" as |form|}}
{{#form.element label="User Name" property="username" as |el|}}
<div class="input-group">
<input value={{el.value}} placeholder="Username" class="form-control" oninput={{action (mut el.value) value="target.value"}} id={{el.id}} type="text" autofocus="true">
<div class="input-group-addon"><i class="icon-user"></i></div>
</div>
{{/form.element}}
{{#form.element label="Email Address"property="email" as |el|}}
<div class="input-group">
<input value={{el.value}} placeholder="Email Address" class="form-control" oninput={{action (mut el.value) value="target.value"}} id={{el.id}} type="email">
<div class="input-group-addon"><i class="icon-envelope-open"></i></div>
</div>
{{/form.element}}
{{#form.element label="Password"property="password" as |el|}}
<div class="input-group">
<input value={{el.value}} placeholder="Password" class="form-control" oninput={{action (mut el.value) value="target.value"}} id={{el.id}} type="password">
<div class="input-group-addon"><i class="icon-lock"></i></div>
</div>
{{/form.element}}
{{#form.element label="Confirm Password"property="password_confirmation" as |el|}}
<div class="input-group">
<input value={{el.value}} placeholder="Confirm password" class="form-control" oninput={{action (mut el.value) value="target.value"}} id={{el.id}} type="password">
<div class="input-group-addon"><i class="icon-lock"></i></div>
</div>
{{/form.element}}
<div class="form-group">
<div class="checkbox checkbox-success">
<input id="checkbox_2" required="" type="checkbox">
<label for="checkbox_2"> I agree to all <a class="txt-danger capitalize-font" href="#">terms</a></label>
</div>
</div>
{{#if errorMessage}}
<div local-class="form-group">
<div class="txt-danger">{{errorMessage}}</div>
</div>
{{/if}}
<div class="form-group">
{{bs-button defaultText="Sign up" type="primary" buttonType="submit" class="btn btn-success btn-block"}}
</div>
<div class="form-group mb-0">
<span class="inline-block pr-5">Already have an account?</span>
{{#link-to 'login' class='inline-block txt-danger'}}Sign in{{/link-to}}
</div>
{{/bs-form}}
</div>
import DS from 'ember-data';
import {validator, buildValidations} from 'ember-cp-validations';
const Validations = buildValidations({
username: [
validator('presence', true),
validator('length', {
min: 5,
max: 15
})
],
password: [
validator('presence', true),
validator('length', {
min: 4,
max: 10
}),
validator('format', {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,10}$/,
message: '{description} must include at least one upper case letter, one lower case letter, and a number'
}),
validator('length', {
isWarning: true,
min: 6,
message: 'What kind of weak password is that?'
})
],
password_confirmation: [
validator('presence', true),
validator('length', {
min: 4,
max: 10
}),
validator('format', {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,10}$/,
message: '{description} must include at least one upper case letter, one lower case letter, and a number'
}),
validator('length', {
isWarning: true,
min: 6,
message: 'What kind of weak password is that?'
})
],
email: [
validator('presence', true),
validator('format', {type: 'email'})
]
}, {debounce: 500});
export default DS.Model.extend(Validations, {
locale: DS.attr('string'),
email: DS.attr('string'),
username: DS.attr('string'),
first_name: DS.attr('string'),
last_name: DS.attr('string'),
password: DS.attr('string'),
password_confirmation: DS.attr('string'),
birthday: DS.attr('date'),
device_attributes: {
os: DS.attr('string'),
uid: DS.attr('string')
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment