Wilhelm
unread,Dec 1, 2008, 12:44:21 AM12/1/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to erlyweb
Hi all,
Just getting started with erlyweb. I'm currently using the same form
in my views for both new and edit:
<%@ new(Friend) %>
<h2>Create Friend</h2>
<b><% friends:value(friends:first_name(Friend)) %></b><br/>
<form method="post" action="/friends/create">
<input type="submit" value="Create" />
</form>
<% a([".."], "Back") %>
<%@ edit({Friend}) %>
<h2>Edit Friend</h2>
<form method="post" action="/friends/edit">
<% friend_form(Friend) %>
<input type="submit" value="Edit" />
</form>
<% a([".."], "Back") %>
<%@ friend_form(Friend) %>
<table>
<% friend_field(Friend, first_name) %>
<% friend_field(Friend, last_name) %>
<% friend_field(Friend, picture) %>
</table>
<%@ friend_field(Friend, FieldName) %>
<tr>
<td>
<input type="text"
name="<% atom_to_list(FieldName) %>"
value="<% friends:FieldName(Friend) %>" />
</td>
</tr>
This doesn't work for the new page since the FieldName for a Friend is
empty. What do I do so that I can use the same form code for both new
and edit, so that it doesn't crash the code?
I've tried using this function instead of calling friends:FieldName
(Friend) directly:
value(Val) ->
case Val of
undefined ->
"";
_ ->
Val
end.
But it craps out with:
ERROR erlang code crashed:
File: appmod:0
Reason: {badarg,[{erlydb_base,get,2},
{erlyweb,'-render_response_body/7-fun-0-',6},
{erlyweb,'-render_response_body/7-fun-1-',3},
{lists,map,2},
{erlyweb,render_response_body,7},
{erlyweb,handle_request,6},
{yaws_server,deliver_dyn_part,8},
{yaws_server,aloop,3}]}
Req: {http_request,'GET',{abs_path,"/myapp/friends/new"},{1,1}}
What am I doing wrong?