Skip to content

Commit

Permalink
fixed issue with form.structure resetting form and fixed showcase for…
Browse files Browse the repository at this point in the history
… update_form
  • Loading branch information
mdipierro committed Aug 6, 2023
1 parent a83b301 commit 021a357
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 6 additions & 4 deletions apps/showcase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .examples.auth_form import auth_form
from .examples.auth_forms import auth_forms
from .examples.create_form import create_form
from .examples.update_form import update_form
from .examples.custom_form import custom_form
from .examples.example_ajax_grid import example_ajax_grid
from .examples.example_html_grid import example_html_grid
Expand All @@ -42,7 +43,6 @@
from .examples.show_a_button import show_a_button
from .examples.socketio import index as socketio
from .examples.test_expose import test_expose1, test_expose2, test_expose3
from .examples.update_form import update_form
from .vue_components_examples.vue_view_form import vue_view_form
from .vue_components_examples.vue_insert_form import vue_insert_form
from .vue_components_examples.vue_edit_form import vue_edit_form
Expand All @@ -59,6 +59,8 @@ def index():
@action("show/<name:path>")
@action.uses("show.html")
def show(name):
path = name
name = name.rstrip("/0123456789")
data = []
filename = f"apps/showcase/{name}.md"
if os.path.exists(filename):
Expand Down Expand Up @@ -89,8 +91,8 @@ def show(name):
filename = other[1:].replace(".", "/") + ".py"
with open(f"apps/showcase/{filename}") as stream:
content = stream.read().strip()
data.append({"name": filename, "content": content, "language": "python"})
data.append({"shortname": filename, "content": content, "language": "python"})
# drop the subfolder name
name = "/".join(name.split("/")[1:])
path = "/".join(path.split("/")[1:])
executable = MODE == "full" or name in globals()
return {"files": data, "mode": MODE, "name": name, "executable": executable}
return {"files": data, "mode": MODE, "path": path, "executable": executable}
2 changes: 1 addition & 1 deletion apps/showcase/templates/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<a role="button" href="../index">Back to Examples</a>
[[if executable:]]
<a role="button" href="../[[=name]]">Run Example</a>
<a role="button" href="../[[=path]]">Run Example</a>
[[else:]]
Run this application locally to try examples
[[pass]]
Expand Down
3 changes: 1 addition & 2 deletions py4web/utils/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ def __init__(
self.vars.update(validated_vars)
if dbio:
self.update_or_insert(validated_vars)
self.clear()
elif dbio:
self.deleted = True
self.record.delete_record()
Expand Down Expand Up @@ -928,8 +929,6 @@ def clear(self):
)

def helper(self):
if self.accepted:
self.clear()
if not self.cached_helper:
helper = self.param.formstyle(
self.table,
Expand Down

0 comments on commit 021a357

Please sign in to comment.