Reputation: 2451
I'm creating a custom file upload form in Web2Py, and was hoping some more experienced users could help me solve a few issues. Basically, the database ("t_file") is defined in "db_wizard.py", and in the controller, I'm calling crud.create(db.t_file, next=URL('upload')); a form is added in the html file with {{form}}.
There are about a dozen fields created, two of which are selectors, one is a file upload/browse field, and the rest are input boxes. I would like to make the following changes:
-Currently, the selectors default to an empty option. They are defined in the DB file like this:
Field('f_data_real_or_fabricated_bool', 'list:string', requires=IS_IN_SET(['T','F']), label=T('Real or Fabricated')),
However. when displayed, the first option is empty, and the two other options are below the empty option. Is there a way to get rid of the empty option?
-The regular text input boxes, the selector boxes, and the filename input box are different widths. What is the best way to make them the same width? I've been trying all sorts of things with the CSS, but can't seem to get it.
-Is there a way to use expandable text boxes for some of text input areas?
-I would like the first several input fields to be required, and the rest to be optional. The mandatory fields should appear on the upload page by default, and the rest optional fields should only appear when an "advanced fields" (something along those lines) checkbox is checked. What is the best way to do this?
Can the above changes be made by sticking with the crud.create or crud.* methods, without designing custom forms?
Upvotes: 1
Views: 809
Reputation: 161
I think you should attack one thing at the time and, for each one, try paste some code that helps a lot. I try to answer the last question: I think you won't be able to do that with crud interface without change the inner code (DO NOT DO THAT!). With SQLFORM, you can, altering CSS on Fields. But, the best and more controllable, although more hard work, is creating custom forms.
Upvotes: 0