How to Create a Database User Input Form in 5 Minutes

I recently created a component palette that contains pre-configured components for quickly creating database-backed user input forms in Ignition. More information about it can be found here: nickmudge.info/post/new-componen … n-Ignition

I attached the project file that contains the Form Components palette and a Python module that the components use. Import the project file into a project to use the new form components.

I also recorded a video of myself creating a database-backed user input form from scratch in less than five minutes. The video is here: youtube.com/embed/nh_ksHFEz … 0&vq=hd720

Another video I made shows better information about how the new form components work. It is here: youtube.com/embed/hZO5YQALk … 0&vq=hd720
FormComponentsPalette.proj (36.7 KB)

5 Likes

Uh… that is awesome! I am definitely going to check this out. Very nice work, Nick!

Nice! Though for me it would be ‘Under 15 Minutes’. You just type faster that I do! :smiley:

1 Like

I changed over an editable table to this in under 20 minutes and I only had to watch the Youtube video once, so that’s a win! I’m very impressed. If you get some extra time it would be nice if you could do a little write up about the python scripting behind it, I don’t fully understand how all of it works. I think this is the first time I’ve seen classes used in an Ignition python script module. I’m not following how those class instances get created and manipulated.

But this is great stuff! I will put this to good use, thanks for sharing and making it available to everyone!

Nick

Very nice, I tried it out today as I have a project that this will be useful with.

I’ll seek you out at the ICC next week and have a chat.

Great guys.

Duffanator, here’s to answer your question about classes in the project.pa.forms Python module:
The FormInput class is defined and used as a way to treat all form input components the same way.

A new instance of a FormInput class is created by passing in a form input component argument to the constructor, like this: formInputInstance = FormInput(formInputComponent). A FormInput instance provides a common set of methods to access data and functionality for any form input component.

New instances of the FormInput class are created in one place, in the getInputs function, which is here:

def getInputs(formContainer):
	"""
	Get all form input components in a Form Container.
	"""
	inputs = []
	for comp in formContainer.getComponents():
		if isinstance(comp,BasicContainer):
			if not hasattr(comp,"Column"):
				inputs.extend(getInputs(comp))
				continue
			inputs.append(FormInput(comp))
	return inputs

Notice this line: “inputs.append(FormInput(comp))”. This is creating a new FormInput instance from a form input component and appending it to the list of other FormInput instances.

The form input components are the form components that have a “Column” custom property. Some of these are the “Form Text Field”, “Form Numeric Text Field”, “Form Dropdown List” and “Form Radio Buttons”.

The getInputs function finds each input form component, creates a FormInput instance with it and adds it to a list. When all the input form components are found the list of FormInput instances are returned.

Here’s a couple examples to show you how this is used. Normally to get the value from a Form Text Field component you have to use this code:

value = formTextField.getComponent("Text Field").text

And if you want to get a value from the Form Dropdown List component you have to use this code:

dropdownList = formDropdownList.getComponent("Dropdown List")
value = getattr(dropdownList,dropdownList.ValueProperty)

But if you create FormInput instances of these two form input components then accessing the value is done in the same way:

formTextField = FormInput(formTextField)
formDropdownList = FormInput(formDropdownList)

value = formTextField.getValue()
value = formDropdownList.getValue()

Besides getValue() the FormInput class provides other uniform functions for form input components such as setValue(), clearValue(), and more can be added as needed in the future.

So the getInputs() function returns a list of all form input componets as FormInput instances. This makes it easy to loop through all form inputs and perform an operation on all of them. For example:

inputs = getInputs(formContainer)
for input in inputs:
	print input.getValue()

How is this? Any other questions?

Best,

Chris Taylor, I look forward to meeting you at the conference.

Very Nice.

Perfect… Thanks a lot . :thumb_left: :thumb_left: :thumb_left: :thumb_left:

The addition of a dropdown calendar form component for selecting datetimes would be nice.

[quote=“Duffanator”]The addition of a dropdown calendar form component for selecting datetimes would be nice.[/quote]Yes, indeed. Today I released exactly that: a new Form Popup Calendar component and a new Form Check Box component. See the blog post here: nickmudge.info/post/new-form-pop … components

Ahhh, perfect! I actually made my own drop down calendar component but yours works better. The check box is also a nice addition. Thanks Nick!

whats the best way to have the form component access two different tables, ie… Insert into one and read from another, would just nested form containers work?

Hi Nick,

I’m using 7.6.4 and I was wondering if there would be any problems using your form pallet?

Hi Clkman,

Because the project file was created using Ignition 7.7.2 it can only be imported into an Ignition server that is 7.7.2 or above. Sorry about that.

Best,

Watch the video - this will save me MANY hours of work…
Alas, the link to the PROJ does not work.
Hopefully it can be fixed and I can start using this!

The .proj link in the OP didn’t work for me, however, going through to Nick’s website (1st link) and downloading it there did work.

Has anyone seen any issues with this under 7.9.8/9?

You will probably have to enable the legacy database access permissions for the project. Ignition introduced named queries a few versions ago and the legacy db access permissions are turned off by default for new projects.

None of the links seem to be working. Is this project still available?