0

Consider this new-food.html:

<form>
  <h2>Food Name</h2>
  <input type="text" name="food" value="%(foodname)s">

  <h2>Sides:<h2>
  <input type="checkbox" name="sides"  value="with_salad"> With Salad
  <input type="checkbox" name="sides"  value="with_fries"> With Fries

  <input type="submit">
</form>

On submit, it will create a food entity with these items saved ['apple', 'mango']. What happens when we want to edit this entity? The %(foodname)s will preserve the Food Name text field, but how do we preserve the checkbox fields uploading of the page, like this:

  <input type="checkbox" name="sides"  value="with_fries" checked> With Fries
hyang123
  • 1,208
  • 1
  • 13
  • 32

1 Answers1

1

In app engine Python you can use Jinja2 for server side templating:

<form>
  <h2>Food Name</h2>
  <input type="text" name="food" value="{{ foodname }}">

  <h2>Sides:<h2>
  <input type="checkbox" name="sides"  value="with_salad" {% if sides == "with_salad" %}checked{% endif %}> With Salad
  <input type="checkbox" name="sides"  value="with_fries" {% if sides == "with_fries" %}checked{% endif %}> With Fries

  <input type="submit">
</form>

See the docs: https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates

voscausa
  • 11,253
  • 2
  • 39
  • 67
  • Thank you @voscausa. From your profile, I have noticed that you are very knowledegable in GAE. If you wouldn't mind, I would love your help in this question also: http://stackoverflow.com/questions/20025241/google-appengine-form-handling-repeated-structuredproperty. I am hoping to build a much needed jobs marketplace for a developing country. – hyang123 Nov 27 '13 at 00:00