forked from nitrogen/nitrogen_core
-
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 html_name to following elements
added records for restful_form restful_submit restful_reset modified: wf.hrl added restful elements new file: ../src/elements/forms/element_restful_form.erl new file: ../src/elements/forms/element_restful_submit.erl added html_name attribute: modified: ../src/elements/forms/element_button.erl modified: ../src/elements/forms/element_checkbox.erl modified: ../src/elements/forms/element_hidden.erl modified: ../src/elements/forms/element_password.erl modified: ../src/elements/forms/element_radio.erl modified: ../src/elements/forms/element_textarea.erl modified: ../src/elements/forms/element_textbox.erl replaced tabs with space in element_textarea.erl added html_name() modified: ../src/lib/wf_tags.erl moved some internal functions to wf_utils modified: ../src/lib/wf_utils.erl modified: ../src/elements/forms/element_inplace.erl
- Loading branch information
Showing
13 changed files
with
148 additions
and
40 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
% Nitrogen Web Framework for Erlang | ||
% Copyright (c) 2012 Steffen Panning | ||
% See MIT-LICENSE for licensing information. | ||
|
||
-module (element_restful_form). | ||
-include_lib ("wf.hrl"). | ||
-export([reflect/0, render_element/1]). | ||
|
||
-define(IS_FORM(Tag), ( Tag == element_button orelse | ||
Tag == element_checkbox orelse | ||
Tag == element_hidden orelse | ||
Tag == element_password orelse | ||
Tag == element_radio orelse | ||
Tag == element_textarea orelse | ||
Tag == element_textbox orelse | ||
% Tag == element_upload orelse | ||
Tag == element_restful_submit)). | ||
|
||
reflect() -> record_info(fields, restful_form). | ||
|
||
render_element(Record) -> | ||
?PRINT("START RENDER"), | ||
WithName = inject_name(Record), | ||
wf_tags:emit_tag(form, WithName#restful_form.body, [ | ||
wf_tags:html_name(WithName#restful_form.id, | ||
WithName#restful_form.html_name), | ||
{action, WithName#restful_form.action}, | ||
{method, WithName#restful_form.method} | ||
]). | ||
|
||
%%internal | ||
inject_name(Element) | ||
when is_tuple(Element) -> | ||
?PRINT("START INJECT"), | ||
Base = wf_utils:get_elementbase(Element), | ||
Module = Base#elementbase.module, | ||
Fields = Module:reflect(), | ||
New = set_html_name(Module, Fields, Element), | ||
case wf_utils:get_field(body, Fields, New) of | ||
undefined -> New; | ||
Body -> NewBody = [inject_name(N) || N <- Body], | ||
wf_utils:replace_field(body, NewBody, Fields, New) | ||
end; | ||
inject_name(Element) -> | ||
Element. | ||
|
||
set_html_name(Tag, Fields, Rec) | ||
when ?IS_FORM(Tag) -> | ||
?PRINT("START SET_HTML_NAME"), | ||
{ID, Name} = {wf_utils:get_field(id, Fields, Rec), | ||
wf_utils:get_field(html_name, Fields, Rec)}, | ||
{_, NewName} = wf_tags:html_name(ID, Name), | ||
wf_utils:replace_field(html_name, wf_utils:normalize_id(NewName), Fields, Rec); | ||
set_html_name(_Tag, _Fields, Rec) -> | ||
Rec. |
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,26 @@ | ||
% Nitrogen Web Framework for Erlang | ||
% Copyright (c) 2012 Steffen Panning | ||
% See MIT-LICENSE for licensing information. | ||
|
||
-module (element_restful_submit). | ||
-include_lib ("wf.hrl"). | ||
-compile(export_all). | ||
|
||
reflect() -> record_info(fields, restful_submit). | ||
|
||
render_element(Record) -> | ||
ID = Record#restful_submit.id, | ||
Anchor = Record#restful_submit.anchor, | ||
case Record#restful_submit.postback of | ||
undefined -> ignore; | ||
Postback -> wf:wire(Anchor, #event { type=click, validation_group=ID, postback=Postback, delegate=Record#restful_submit.delegate }) | ||
end, | ||
|
||
Value = [" ", wf:html_encode(Record#restful_submit.text, Record#restful_submit.html_encode), " "], | ||
wf_tags:emit_tag(input, [ | ||
{type, submit}, | ||
{name, Record#restful_submit.html_name}, | ||
{class, [restful_submit, Record#restful_submit.class]}, | ||
{style, Record#restful_submit.style}, | ||
{value, Value} | ||
]). |
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