2

Pyramid を使用した単純なフォームがあり、それを新規または更新として使用したいと考えています。フォームのすべてのフィールドに空の辞書値を作成する必要は特にありません。例外を発生させずに無視したいだけです。

<div metal:fill-slot="content">
<form method="POST" action="/studentupdate">
    <input name="id" value="${studentid}" type="hidden" />
    Name: <input type="text" name="studentname" value="${studentname}"/><br />
    Exam Score: <input type="text" name="studentexam" value="${studentexam}"/><br />
    Quiz Score: <input type="text" name="studentquiz" value="${studentquiz}"/><br />
    Homework Score: <input type="text" name="studenthomework" value="${studenthw}"/><br />
    <input type="submit" value="Save"/>
</form>
</div>

これどうやってするの?

ありがとう。

4

1 に答える 1

0

このような回避策ができます
${studentexam or ''}

% for i in missing_list or []
<li>${i}</li>
% endfor
于 2015-02-04T07:10:48.317 に答える