|
1 |
| -[#623] Refactor to use SimpleForm |
| 1 | +# Remaining Tasks: |
2 | 2 |
|
3 |
| -* Convert the existing forms to use simple rather than our custom form code. |
| 3 | +* Move all the manual initializers in dummy into the engine. |
4 | 4 |
|
| 5 | +[#623] Refactor CMS forms to use SimpleForm |
5 | 6 |
|
6 |
| -## Remaining Tasks: |
| 7 | +Converted all the internal forms to use SimpleForm rather than our own custom form builder. This provides better consistency with bootstrap forms, as well as well tested API for defining new form inputs. This will primarily affect developers when they create content blocks. New content will be generated using simple_form syntax like so: |
7 | 8 |
|
8 |
| -* Move all the manual initializers in dummy into the engine. |
9 |
| -* Write documentation |
| 9 | +<%= f.input :photo, as: :file_picker %> |
| 10 | + |
| 11 | +rather than the older syntax that looks like this: |
| 12 | + |
| 13 | +<%= f.cms_file_field :photo %> |
| 14 | + |
| 15 | +The old form_builder methods like cms_text_field and cms_file_field have been deprecated and will generate warnings when used. These methods are scheduled for removal in BrowserCMS 4.1. It's recommended that custom content blocks be upgraded to use the new syntax when feasible. The deprecation warnings should provide some guideance, but also look at simple_forms documentation http://simple-form.plataformatec.com.br for help. |
| 16 | + |
| 17 | +## Available Input Types |
| 18 | + |
| 19 | +All of the existing simple_form input mappings are available. See http://simple-form.plataformatec.com.br/#mappings-inputs-available for the reference. BrowserCMS adds some additional input types for specific CMS features. |
| 20 | + |
| 21 | +|# Mapping | Input | Purpose/column type #| |
| 22 | +| file_picker | File Upload | A single attachment with section/path selectors | |
| 23 | +| cms_text_area | text area | Like :text but with a :default | |
| 24 | +| cms_text_field | text field | Like :string with optional path generator (for addressable content types)| |
| 25 | +| date_picker | jquery date select | date | |
| 26 | +| path | text field | A slug/path for addressable content (works with cms_text_field to automatically generate names) | |
| 27 | +| template_editor | text area | For editing templates via ERB or other permitted template languages. | |
| 28 | +| text_editor | WYSIWYG editor | For editing HTML content (has toggle to use a text area | |
| 29 | +| attachments | Multiple File Uploads | Unlimited # of attachments. | |
| 30 | +| tag_list| text field | has_many with :tags | |
| 31 | + |
| 32 | +### Usage |
| 33 | + |
| 34 | +Here are some examples showing how to use the CMS specific inputs. |
| 35 | + |
| 36 | +``` |
| 37 | +<%= f.input :name, as: :cms_text_field, default: "Some Value" %> |
| 38 | +``` |
| 39 | + |
| 40 | +Generates the 'name' field, and a :path input if the content block is addressable. Can supply a default value that will be used when creating a new record. |
| 41 | + |
| 42 | +``` |
| 43 | +<%= f.input :expires_on, as: :date_picker %> |
| 44 | +``` |
| 45 | + |
| 46 | +Renders a text_field that can be left blank or have a date entered into it as text. Clicking on it will bring up a JQuery Date Picker to select the date. |
| 47 | + |
| 48 | +``` |
| 49 | +<%= f.input :template, as: :template_editor %> |
| 50 | +``` |
10 | 51 |
|
11 |
| -## Steps |
| 52 | +Renders a template editor (if the content block has enabled template editing). The default template body for the model will be used when creating a new record. |
12 | 53 |
|
13 |
| -10. Move all the manual initializers in dummy into the engine. |
14 |
| -10. Ensure we don't conflict with existing simple_form implementations |
15 | 54 |
|
| 55 | +### Usage Exceptions |
16 | 56 |
|
17 |
| -## Upgrade/Documentation notes |
| 57 | +Several of the input types above are not used directly, but rather via methods like this that hide some of their complexity: |
18 | 58 |
|
19 |
| -* For content_blocks that want to be addressable, they need as: :cms_text_field rather than the default. |
20 |
| -* Docs: Provide reference for content blocks, link to simple form docs as well as provide our specific field types. |
| 59 | +``` |
| 60 | +<%= f.cms_attachment_manager %> |
| 61 | +<%= f.cms_tag_list %> |
| 62 | +``` |
21 | 63 |
|
22 |
| -## Bugs |
23 | 64 |
|
24 |
| -* Tag list does not automatically suggest tags. |
|
0 commit comments