-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
92 additions
and
118 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
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Formbuilder | ||
module Views | ||
class Form < Erector::Widget | ||
|
||
needs :form, :entry, action: '', method: 'POST' | ||
|
||
def content | ||
form_tag @action, method: @method, class: 'formbuilder-form', multipart: true do | ||
fields | ||
actions | ||
end | ||
end | ||
|
||
# @todo csrf | ||
|
||
def fields | ||
@form.response_fields.each do |rf| | ||
widget Formbuilder::Views::FormField.new(response_field: rf, entry: @entry) | ||
end | ||
end | ||
|
||
def actions | ||
div(class: 'form-actions') { | ||
button.button.primary 'Submit' | ||
} | ||
end | ||
|
||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Formbuilder | ||
module Views | ||
class FormField < Erector::Widget | ||
|
||
needs :response_field, :entry | ||
|
||
def content | ||
@value = @entry.try(:response_value, @response_field) | ||
|
||
div(class: "fb-field-wrapper response-field-#{@response_field.field_type} #{@entry.try(:error_for, @response_field) && 'error'}") { | ||
render_label if @response_field.input_field | ||
rawtext @response_field.render_input(@value, entry: @entry) | ||
div.clear | ||
render_error if @response_field.input_field && @entry.error_for(@response_field) | ||
render_description if @response_field.input_field && @response_field[:field_options]["description"].present? | ||
} | ||
end | ||
|
||
private | ||
def render_label | ||
label(for: "response_fields_#{@response_field.id}") { | ||
text @response_field[:label] | ||
abbr('*', title: 'required') if @response_field.required? | ||
} | ||
end | ||
|
||
def render_error | ||
span(class: "help-block validation-message-wrapper") { | ||
text @entry.error_for(@response_field) | ||
} | ||
end | ||
|
||
def render_description | ||
span(class: 'help-block') { | ||
text simple_format(@response_field[:field_options]["description"]) | ||
} | ||
end | ||
|
||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Views::Test::Form < Formbuilder::Views::Form | ||
end |
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 |
---|---|---|
@@ -1 +1 @@ | ||
<%= Formbuilder::FormRenderer.new(@form, @entry).to_html %> | ||
<%= render partial: 'form' %> |
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
1 change: 0 additions & 1 deletion
1
spec/dummy/public/uploads/formbuilder/entry_attachment/upload/1/text.txt
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.