Form Data Validation

33 views
Skip to first unread message

Aurlus Ismael

unread,
Feb 16, 2018, 2:08:31 AM2/16/18
to ChicagoBoss
Hi all,

I'm new to Erlang and ChicagoBoss. I've been looking around to see if there's a way to do form validation e.g test if a particular field is empty, and return the form
with the relevant errors. Is there a way to do this?

Kai Janson

unread,
Feb 16, 2018, 2:10:19 AM2/16/18
to chica...@googlegroups.com
Yes, there is. I’ll have to go through my sources tomorrow but I’ve done it before.

I think it was a combination of controller code and JavaScript.

Thank you.

Kai Janson
Relator • Ideation • Learner • Individualization • Strategic
Achiever • Futuristic • Belief • Restorative • Developer
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/02aadda4-829b-411f-b7b8-0fe6abfdc5bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aurlus Ismael

unread,
Feb 16, 2018, 2:11:48 AM2/16/18
to ChicagoBoss
Thanks for the prompt response. I'll be waiting for your response.

Nick Garanko

unread,
Feb 16, 2018, 8:48:51 AM2/16/18
to ChicagoBoss
Heya Aurlus,

Long ago I build basic implementation of Django-alike form validation: https://github.com/ngaranko/boss_form
Example: 

Unfortunately long since had no time/will to contribute in there, maybe it's good time now to return to it. Thus: will be happy to assist extending it.

-Nick

Op vrijdag 16 februari 2018 08:11:48 UTC+1 schreef Aurlus Ismael:

Aurlus Ismael

unread,
Feb 17, 2018, 2:41:35 PM2/17/18
to ChicagoBoss
Hi Nick,

Thanks for your library and the examples. However, I'm having an undefined stacktrace when I try initiating the form.

Error in controller error:undef Stacktrace: [{boss_form,new,[login_form,[]],[]}...]

Any suggestions to get past this?

Nick Garanko

unread,
Feb 18, 2018, 4:33:13 AM2/18/18
to Aurlus Ismael, chica...@googlegroups.com
Ouch, forgot to mention:
 You have to add following into deps section of rebar.config
```
{boss_form, ".*", {git, “https://github.com/ngaranko/boss_form.git", "HEAD”}}
```

And then run: ./rebar get-deps compile
I’ve just pushed an update to controller code in r2d2 repo that fixes a bug in form processing, FYI.

-Nick
--
You received this message because you are subscribed to a topic in the Google Groups "ChicagoBoss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chicagoboss/4mu7obiiHqk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chicagoboss...@googlegroups.com.

Aurlus Ismael

unread,
Feb 19, 2018, 1:49:46 AM2/19/18
to ChicagoBoss
Thanks for that Nick. I already had that as I was getting the error. I changes the position of boss_form in rebar.config and now I have a different issue:

09:44:49.807 [error] Unhandled Error: error:function_clause Stacktrace: [{boss_web_controller_handle_request,process_result,[{boss_app_info,
                                                    asm_dashboard,[],
                                                    "/static","/doc",all,
                                                    [{asm_dashboard_01_news,
                                                      [0]}],
                                                    <0.295.0>,<0.296.0>,
                                                    <0.298.0>,<0.299.0>,
                                                    ["asm","greeting"],
                                                    [],
                                                    ["asm_dashboard_asm_controller",
                                                     "asm_dashboard_dispatch_controller",
                                                     "asm_dashboard_greeting_controller"]},
                                                   {sbw,cowboy_simple_bridge,
                                                    {cowboy_bridge,
                                                     #Ref<0.3139497015.3672375297.49461>},
                                                    false,[],[],[],none,
                                                    [{<<"host">>,
                                                      <<"127.0.0.1:8001">>},
                                                     {<<"connection">>,
                                                      <<"keep-alive">>},
                                                     {<<"cache-control">>,
                                                      <<"max-age=0">>},
                                                     {<<"user-agent">>,
                                                      <<"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36">>},
                                                     {<<"upgrade-insecure-requests">>,
                                                      <<"1">>},
                                                     {<<"accept">>,
                                                      <<"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8">>},
                                                     {<<"accept-encoding">>,
                                                      <<"gzip, deflate, br">>},
                                                     {<<"accept-language">>,
                                                      <<"en-US,en;q=0.9">>},
                                                     {<<"cookie">>,
                                                      <<"_ga=GA1.1.954076321.1512824233; __zlcmid=jtgxPXLkmmbTy0; csrftoken=QcRQOtrXSldsDpCURTVHygYbLhItucLn; sessionid=rpwb5m5j7dlttzrjosx8t3jimmv3qoy6; _boss_session=d1718a457590314fc6bd530c6cdeb9fd62d784c5">>}],
                                                    [{<<"_ga">>,
                                                      <<"GA1.1.954076321.1512824233">>},
                                                     {<<"__zlcmid">>,
                                                      <<"jtgxPXLkmmbTy0">>},
                                                     {<<"csrftoken">>,
                                                      <<"QcRQOtrXSldsDpCURTVHygYbLhItucLn">>},
                                                     {<<"sessionid">>,
                                                      <<"rpwb5m5j7dlttzrjosx8t3jimmv3qoy6">>},
                                                     {<<"_boss_session">>,
                                                      <<"d1718a457590314fc6bd530c6cdeb9fd62d784c5">>}],
                                                    {response,200,[],[],[]}},
                                                   {{ok,
                                                     [{a,b},
                                                      {form,
                                                       {login_form,[],[...

Nick Garanko

unread,
Feb 19, 2018, 4:27:28 AM2/19/18
to Aurlus Ismael, chica...@googlegroups.com
Could you share some code, please?

-Nick

Aurlus Ismael

unread,
Feb 19, 2018, 4:39:27 AM2/19/18
to ChicagoBoss
login('GET', [], Context) ->
case proplists:get_value(user_no, boss_session:get_session_data(SessionID)) of
undefined ->
Form = boss_form:new(login_form, []),
io:format("FORM: ~p~n~n", [Form:fields()]),
{{ok, [{a, 'b'}, {form, Form}]}, Context};
_ ->
{{redirect, "/team_performance"}, Context}
end;

It fails on the form initialization line.

medical.o...@gmail.com

unread,
Feb 25, 2018, 1:58:21 AM2/25/18
to ChicagoBoss
You mean like the way the ChicagoBoss tutorial.pdf does the exact thing you describe? 

Aurlus Ismael

unread,
Feb 26, 2018, 1:25:41 AM2/26/18
to chica...@googlegroups.com
Chicago boss tutorial does it on model level. I was attempting to do it just on form level.

--
You received this message because you are subscribed to a topic in the Google Groups "ChicagoBoss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chicagoboss/4mu7obiiHqk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chicagoboss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Aurlus I. Wedava
Software Engineer, Twiga Foods Ltd. 
Tel: +254 (0) 701 783003

Building Modern Markets
Reply all
Reply to author
Forward
0 new messages