Skip to content

Commit

Permalink
Added some documentation on initial values.
Browse files Browse the repository at this point in the history
  • Loading branch information
sxross committed Jan 16, 2013
1 parent a542e1b commit e975652
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ To add your own, check [the guide to adding new row types](https://github.com/cl

`Formotion::Form`, `Formotion::Section`, and `Formotion::Row` all respond to a `::PROPERTIES` attribute. These are settable as an attribute (ie `section.title = 'title'`) or in the initialization hash (ie `{sections: [{title: 'title', ...}]}`). Check the comments in the 3 main files (`form.rb`, `section.rb`, and `row.rb` for details on what these do).

### Setting Initial Values

Forms, particularly edit forms, have default initial values. You can supply these in the `:value` attribute for a given row. So, for example:

```ruby
{
title: "Email",
key: :email,
placeholder: "[email protected]",
type: :email,
auto_correction: :no,
auto_capitalization: :none,
value: '[email protected]'
}
```

Setting values for non-string types can be tricky, so you need to watch what the particular field expects. In particular, date types require
the number of seconds from the beginning of the epoch as a number.

### Retrieve

You have `form#submit`, `form#on_submit`, and `form#render` at your disposal. Here's an example:
Expand Down

0 comments on commit e975652

Please sign in to comment.