Skip to content

Instantly share code, notes, and snippets.

@alecperkins
Created November 4, 2013 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecperkins/7307518 to your computer and use it in GitHub Desktop.
Save alecperkins/7307518 to your computer and use it in GitHub Desktop.
Doodad extensibility
# Extend the Components as a way to provide defaults or add extra capability.
class TitleField extends StringField
placeholder : 'Title'
label : 'Title'
char_limit : 70
getValue: ->
value = super()
# do something with the value
return value
# Extend Container components for a more declarative way of assembling the interface.
# Imperitive method still available when more logic is necessary.
class CustomForm extends Form
layout: """
title,subtitle cover:200
description save_button
"""
# Called when initializing the form. Provides the form instance for use
# by the components.
fields: (form) ->
title : new TitleField()
subtitle : new StringField
char_limit: 100
description : new StringField
type: 'multiline'
char_limit: '~300'
cover : new ImageField()
save_button: new Button
on: click: ->
form.save()
new CustomForm
model: issue_model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment