Jump to content
Morgawr

Getting really confused: how to create forms for my own database

Recommended Posts

Hey guys.. I'm a newbie with processwire, I have to say it's a really good CMS, however I'm having some problems and I'm REALLY confused about the whole layout of the CMS and how to get around it

At the moment I have two databases, one is the processwire database used for the whole website yadda yadda. The other one is a database of stuff I need (it also interfaces with other applications, that's why I didn't put it inside the processwire DB).

I want to create a frontend for managing said database (adding fields, rows, etc etc). Basically what I have in mind is something like: and send data to my database when an admin submits the form.

Anyhow, I'm getting that far and it's all good, however I have a huge trouble with understanding how the whole $modules->get("whatever"); works.

What is "InputfieldForm"? what is "InputfieldText"? I mean, they are quite straightforward but now I also need to add a select (aka drop down menu) field. I downloaded the drop down menu module created by Hani but I'm not sure if that is even related to what I'm asking here.

Can someone please help me? What I want ultimately in my form is to have a drop down menu with 3-4 options. I'm getting really confused, thanks :)

Share this post


Link to post
Share on other sites
What is "InputfieldForm"? what is "InputfieldText"?

Take out the "Inputfield" part, and it describes what the field is. For instance "Form" is a <form> and "Text" is an <input type="text">

I also need to add a select (aka drop down menu) field. I downloaded the drop down menu module created by Hani but I'm not sure if that is even related to what I'm asking here.

You want to use the InputfieldSelect included with ProcessWire:

$select = $modules->get('InputfieldSelect');
$select->name = 'my-select-field';
$select->addOption('A', 'Option A');
$select->addOption('B', 'Option B');
$select->addOption('C', 'Option C'); 
$select->value = 'B'; // if you want to set a predefined value
$form->add($select);
  • Like 3

Share this post


Link to post
Share on other sites

These are great indications, Ryan. As always, very clear and so helpful. Thank you!

While on those 'confusing' issues with forms, how about InputfieldPassword. If I use it, I get 2 fields : 1 for password and 1 for confirmation. Would it be possible to limit it to the first field only? If not, how can we integrate such a password field in a form created via the API?

To understand these issues more clearly, I keep trying to find information on the Forum and to look at the code in wire/modules/Inputfield/ and try and analyze it. Is there another place we could find information about this?

Thanks.

Share this post


Link to post
Share on other sites

Just use a text field and make the type = password.

$field->attr('type','password');
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...