Last active
September 22, 2017 07:08
-
-
Save dalgard/a844f6569d8f471db9a7 to your computer and use it in GitHub Desktop.
(Meteor) Customizing field layout in useraccounts:semantic-ui with the use of aldeed:template-extension
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
// Adding some simplistic fields | |
AccountsTemplates.addFields([ | |
{ | |
_id: "address", | |
type: "text", | |
// Options object with custom properties for my layout | |
options: { | |
// Put a divider before this field | |
dividerBefore: true | |
} | |
}, | |
{ | |
_id: "zipcode", | |
type: "text", | |
options: { | |
// Make this field the first in a row of fields | |
startRow: true | |
} | |
}, | |
{ | |
_id: "city", | |
type: "text", | |
options: { | |
// End the row with this field | |
endRow: true | |
} | |
} | |
]); |
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
<template name="appAtGroupFields"> | |
{{#each fields}} | |
{{#if options.dividerBefore}}<hr>{{/if}} | |
<!-- Collect grouped fields, possibly outputting nothing until the group is ended --> | |
{{#with collectFields this}} | |
{{#if isArray this}} | |
<!-- Group container --> | |
<div class="{{numberToWord this.length}} fields"> | |
{{#each this}} | |
{{> atInput}} | |
{{/each}} | |
</div> | |
{{else}} | |
{{> atInput}} | |
{{/if}} | |
{{/with}} | |
{{/each}} | |
</template> |
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
// https://github.com/aldeed/meteor-template-extension | |
Template.appAtGroupFields.inheritsHelpersFrom("atPwdForm"); | |
Template.appAtGroupFields.helpers({ | |
collectFields: function (field) { | |
var instance = Template.instance(), | |
current_row = instance.current_row; | |
if (field.options && field.options.startRow) { | |
instance.current_row = [field]; | |
} | |
else if (field.options && field.options.endRow) { | |
delete instance.current_row; | |
current_row.push(field); | |
return current_row; | |
} | |
else if (current_row) { | |
current_row.push(field); | |
} | |
else { | |
return field; | |
} | |
}, | |
numberToWord: function (number) { | |
return number_words[number]; | |
}, | |
isArray: _.isArray | |
}); | |
var number_words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", | |
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen"]; |
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
<!-- atPwdForm slightly edited --> | |
<template name="appAtPwdForm"> | |
<div class="at-pwd-form"> | |
<form id="at-pwd-form" action="#" method="POST" novalidate> | |
<!-- Moved the iteration to appAtGroupFields --> | |
{{> appAtGroupFields}} | |
{{#if showForgotPasswordLink}} | |
{{> atPwdLink}} | |
{{/if}} | |
{{> atPwdFormBtn}} | |
</form> | |
</div> | |
</template> |
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
// https://github.com/aldeed/meteor-template-extension | |
Template.appAtPwdForm.replaces("atPwdForm"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You wouldn't happen to know best way of doing this in bootstrap? -- want a row into two columns... having issues.. .