SQLFORM that does not include a submit button

Currently working with the web2py framework, I am faced with a challenge in creating a SQLFORM without a submit button. The issue arises from having multiple forms on the page, some of which share common fields, making it impossible to use SQLFORM.factory(). My goal is to have only one form equipped with a submit button that can effectively handle data input from all other forms present. Any recommendations or insights on the most efficient approach to achieving this?

Answer №1

form1 = SQLFORM(db.table1, buttons=[])

By implementing this code snippet, form one will be displayed without any buttons, including the submit button.

Answer №2

One possible approach is to assign the same value to the _formkey and _formname fields for all forms. Here's an example:

my_form2.formname = my_form1.formname
my_form2.formkey = my_form1.formkey

To manually hide submit buttons, you can try this method:

my_form1.element('input', _type = 'submit')['_style'] = 'display:none'

Keep one submit button with matching formname and formkey values as a way to submit the forms.

When inserting variables into database tables, consider using the following syntax:

db.table1.insert(**db.table1._filter_fields(request.vars))
db.table2.insert(**db.table2._filter_fields(request.vars))

If fields share the same names, there could be potential issues, so exercise caution.

Answer №3

If you're looking to streamline your forms, you can combine multiple SQLFORMs by appending one form to another. This way, you'll have a single "multiple form" with only one submit button. Here's an example of how you can achieve this in your controller:

form1 = SQLFORM(db.table1)
form2 = SQLFORM(db.table2)

form1.append(form2)
if form1.process().accepted:
   #apply filters to the fields from each form and perform desired actions
   response.flash = 'OK'
elif form1.errors:
   response.flash = 'NOT OK'

return dict(form=form1)  

Notice that I interacted solely with form1 in the code above. This is because it serves as the main form and enables you to handle filtering efficiently across all your forms. Hopefully, this explanation proves useful.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm encountering a problem while attempting to upload an image in tkinter using a label

Whenever I attempt to upload an image using tkinter, I encounter an error. I have fetched a gif image and stored it in a file named "image.gif", and saved the picture as "image". #Displaying image using label logo = PhotoImage(file="img.gif") w1 = Label(n ...

Extracting Features: 0% complete, still in progress indefinitely... using Python for a deep learning project comparing dogs vs. cats

import cv2 import numpy as np import os from random import shuffle from tqdm import tqdm ​ TRAIN_DIR = '/home/ajmal/Dogs vs cat/train' TEST_DIR = '/home/ajmal/Dogs vs cat/test' IMG_SIZE = 50 LR = 1e-3 CNN = 'dogsvscat ...

Invalid operator detected in TypeT5

File "/work/09235/kunjal/ls6/TypeT5/train_model.py", line 112, in <module> wrapper = train_spot_model( File "/work/09235/kunjal/ls6/TypeT5/typet5/train.py", line 180, in train_spot_model trainer.fit( File "/home1/ ...

In what way can Python circumvent my existing code and execute subsequent code first?

import asyncio import time async def func(): print('task start') await asyncio.sleep(10) print('task end') async def main(): task1 = asyncio.create_task(func()) task2 = asyncio.create_task(func()) task3 = asy ...

"Difficulty encountered while feeding data into TensorFlow's Tflearning - Error with feed

I am currently tackling a classification challenge using Python. Unfortunately, my knowledge of TensorFlow is still lacking. I've been stuck on the same issue for quite some time now and I'm struggling to find a solution. Your assistance would be ...

What's the reason behind the error message "local variable 'text' referenced before assignment" popping up on my screen?

I am attempting to develop a sharing feature using Python and Django, but when I try to execute the "share" function, an error is returned. Below is the code I am working with: views.py from django.shortcuts import render from basicapp.forms import U ...

Steps for generating grouped and stacked bar charts

Dealing with a large dataset that includes multiple subsidiaries catering to three distinct customer groups across different countries can be quite challenging. Even though the provided example is simplified, the reality involves significantly more subsidi ...

Unable to choose columns other than the first one in a pandas dataframe

I've spent a significant amount of time searching the internet to understand this issue. I tried various solutions, but none have worked so far. The problem lies in reading a tsv file that is tab delimited. import pandas as pd df = pd.read_csv(' ...

Scrapy utilizes AJAX to send a request in order to receive the response of the dynamically generated

Is there a way to efficiently extract data from websites like this? To display all available offers, the "Show More Results" button at the bottom of the page needs to be clicked multiple times until all offers are shown. Each click triggers an AJAX reques ...

Learn how to use tkinter to set up a weekly task schedule starting from a user-selected date

Weekly, I am trying to automate downloading files at a specific time and day chosen by the user, similar to what is displayed in this image. My current challenge involves integrating an inner loop concerning root.mainloop(). I have experimented with both . ...

Utilizing Django fixtures: Importing HTML content as JSON into a Text Field

Currently in the process of transitioning my website to Django from another content management system, I am facing challenges with importing HTML into Django using fixtures. The specific issue revolves around "Events", which is a model within my Django app ...

Error encountered in Python 2.7 with Selenium 2: 'NoneType' object does not possess the attribute 'group'

Having recently delved into the world of Python/Selenium, I've been encountering a persistent roadblock while attempting to adjust some code. Despite my efforts scouring the internet and experimenting with various tweaks for days on end, I find myself ...

Python Column Deletion

I need assistance removing the final two columns from my data frame using Python. The problem lies in the presence of cells with unnecessary values in the last two columns, which do not have headers. Below is the code I have attempted to use. However, as ...

Incorporate a title for each grid within ImageGrid

Currently, I am utilizing matplotlib's mpl_toolkits.axes_grid1.ImageGrid to create two grids, each with a size of (3,3): import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import ImageGrid from graspologic.plot import binary_heatmap, adjplot ...

When using Scrapy shell, calling the fetch response.css method results in an

I'm diving into web scraping with scrapy, looking for details on a specific medication: Before creating a Python spider, I started by examining the headline using scrapy shell: <h1 class="headline mb-3 fw-bolder">Beipackzettel von AZI ...

Unable to find element to click on "Join Now" button in Google Meet using Selenium and Python for browser automation

I am working on creating a web automation tool that can automatically join Google Meet using Selenium with the Firefox driver in Python. So far, I have successfully signed up, muted the microphone, and turned off the camera without any issues. However, I a ...

Python SocketTypeError: troubleshooting socket issues

import socket, sys, string if len(sys.argv) !=4: print ("Please provide the server, port, and channel as arguments: ./ninjabot.py <server> <port> <channel>") sys.exit(1) irc = sys.argv[1] port = int(sys.argv[2]) chan = sys.argv ...

Creating unique message formats for communication between a python client and a socket.io node.js server

Currently, I am attempting to establish communication between a Python client and a Node.js server using Socket.io 0.7. My goal is to send a custom event from the client to the server. To achieve this, I have been referencing the Socket.io documentation o ...

Error in executing Python script within Node.js due to syntax issues

When I attempt to run a Python script using the python-shell package in Node.js, I encounter a SyntaxError: invalid syntax. Node.js code const options = { mode: 'text', pythonPath: '/usr/bin/python3', scriptPath: __dirname ...

Filtering options for plotly dashboard in dropdown format

Below is a dataset along with code that generates a chart: Column A Tools Category role figure Occurences After idx 0 PostgreSQL DatabaseHaveWorkedWith Developer, front-end 38.044286 4 False 1 MySQL DatabaseHaveWorkedWith Developer, front-end 45. ...