0
votes

As a PHP developer quite new to Joomla, I have been running in circles trying to create forms on the web page. I can't find one proper source that easily documents the steps. But after a lot of searching, I found this: http://www.ostraining.com/blog/how-tos/development/getting-started-with-jform/

But I don't know where on my host these files go.

Can some one please outline the steps... I'm not looking for complete code. Just something like:

  1. step one create html form
  2. create xml file with key values like...
  3. ...

An example of including a text box and a date field would be superb.

Basically I want to post the contents and print them out using php.

Once again, I only need the steps. Not entire code. And no 3rd party modules/plugins please.

Thanks!

More info... It seems like my question is too broad. Let's take a case. This is what I want to do.

On the web page, the user sees a form when a menu link is clicked. The form has name and date of birth. After it is input, the form is submitted. The web page must print out an output like "Hello X, your age is Y". X is the name and Y the calculated age.

I DO know how to work with standard PHP. As for my level of expertise with Joomla, I have looked at the docs and created my own template with some very simple modules. If I were to break any rules, I could easily insert the form the 'old fashioned way' inside of index.php. But I know this is just wrong in the Joomla world. I have also considered inserting a form as an article. But I see that there are restrictions with the UI components. For example, I may have to use some additional elements like JQuery to get the date input box.

This is why I wanted to just create it the Joomla way, without depending on any 3rd party component/plugin.

1
It sounds to me like you may be having trouble understanding how to add php, not just how to add a form.Elin

1 Answers

0
votes

It sounds to me like you may be having trouble understanding how to add php, not just how to add a form. The Joomla UI is a UI for end users it's not one for developers. For adding a form you need to have a way to get the form into the UI. That's why people have probably recommended that you use a forms extension, because those provide a simple UI for doing so.

How you make the form is going to depend on what you are doing with it and whether you want to save to the database i.e. is it a search form, a filter in the back end UI, or creating content that you want to save.

Do you want to insert this form inside an article? Or do you want it to be its own separate thing that would have a menu item?

So, for any kind of proper Joomla code you need to make an extension, and in your case I would guess it is probably appropriate to make a plugin. You can use the profile plugin as a model if you want.

In your plugin the way I usually would do it (after doing the usual content plugin work of identifying the event and context and so on) would be to define my fields and fieldsets in an xml file.

Then in your php you would instantiate a JForm and echo out the labels and values the way it is done in all the core forms (i.e. look at the article edit layouts).

Without knowing more about the context and purpose of your form it's hard to give more detailed advice than that. I don't want to put links to docs that are going to just be frustrating for you.