I've been building out a small CRUD system in Rapido for a project. Here are some things I'm in the process of figuring out.
How do I create dropdown menus and checkboxes?
I want this for the edit form for my rapido app
I should be able to select from options instead of using plain text.
My dream solution might support a "SELECT" and "BOOL" type and work something like this:
target: ajax
elements:
title: TEXT
item_type: SELECT
options: ["Plant","Animal"]
title: TEXT
show: BOOL
close:
type: ACTION
label: Close
_save:
type: ACTION
label: Save
_delete:
type: ACTION
label: Delete
My current solution/workaround is to create a BASIC type which will generate the select menu.
This is work in progress but in case it helps someone else...
target: ajax
elements:
title: TEXT
item_select: BASIC
item_type: TEXT
close:
type: ACTION
label: Close
_save:
type: ACTION
label: Save
_delete:
type: ACTION
label: Delete
and then I plan to generate my select menu (something like this, but more dynamically)
def item_select(context):
html = """<select><option>Animal</option><option>Plant</option></select>"""
return html
Regarding the SELECT or BOOLEAN types: I do not plan to extend the abilities of Rapido regarding forms, because we already have other solutions for that (collective.easyform and Plomino, which are both very powerful).
When I need a complex form with Rapido, I usually implement it with collective.easyform, and then I hijack its form rendering from a Rapido element:
And then I get back the submitted values that way:
def save(context):
easy_form = context.content.getParentNode().manager_form
fields = context.modules.easyform.get_schema(easy_form)
record = rapido.get_record(context.content.id)
if not record:
return
for field in fields:
value = context.request.get('form.widgets.' + field)
if value:
try:
value = fields[field].fromUnicode(value)
except:
pass
record[field] = value
elif field in record:
del record[field]
record.reindex()
It's hacky but:
the form schema can be managed via the interface which lets the ability to non-developers to change it the way they want
or it can be managed by importing XML, which is handy for developers