forked from clayallsopp/formotion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some documentation on initial values.
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 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 |
---|---|---|
|
@@ -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: | ||
|