Elxis CMS Forum

Support => General => Topic started by: komang on February 11, 2018, 03:53:15

Title: How to create form using Any Form
Post by: komang on February 11, 2018, 03:53:15
Hi all,

I tried to create a form using "Any Form Plugin". I tried to use the sample form but no form was generated.
Can anyone help me or give me an example of a simple form? I have a very basic PHP and mySQL coding knowledge.

(see the attachment bellow)

Thank you

(http://any form.png)
(http://any form 2.png)
(http://any form 3.png)

Title: Re: How to create form using Any Form
Post by: datahell on February 11, 2018, 19:06:56
Is the AnyForm plugin published?

Extensions > Content plugins > Publish "AnyForm" plugin
Title: Re: How to create form using Any Form
Post by: komang on February 12, 2018, 02:55:56
Hi Datahell,

Yes, the Any Form plugin is already published (the screenshot is attached below).

Thanks for your response

(http://any form 4.PNG)
Title: Re: How to create form using Any Form
Post by: datahell on February 12, 2018, 23:06:53
Strange. If AnyForm is published, the xml form exists, it is integrated correctly into an article it should be displayed. I cant help you without seeing it. If you wish send me a personal message with username/password for your site's administration to check it. Also write me the article you integrated the form.
Title: Re: How to create form using Any Form
Post by: komang on February 13, 2018, 09:06:53
Hi Datahell,

It was my fault. The plugin doesn't work maybe because I put it in a category's description. when I integrated it to an article, the form woks (it send email succesfully).

I have two more question:

1. I read on it help : beside email action it support database,

database: Save submitted form data to a database table (set dbtable parameter in XML file and use #__ as Elxis database prefix).

How can I set the database in XML file? can anyone give me a simple example? assume I want to save the data on the sample to database.

2. Beside send the data via email or save it to database, I want to display it after the user submit the form. I think it should be easy but when I tried it using javascript, it didn't work.

Thank you Datahell and all...
Title: Re: How to create form using Any Form
Post by: datahell on February 13, 2018, 15:01:03
1. You must create the database table. Go to phpmyadmin and create the database table based on the form elements. For each form element create a column in your db table to store the submitted data. Be careful to keep the same order in your xml file. Also add first a column with a primary key.

Example
Asume your form has 3 elements: Firstname, Lastname and Email. Create this db table:

CREATE TABLE elx_anyform_data (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `firstname` VARCHAR(60) DEFAULT NULL,
    `lastname` VARCHAR(60) DEFAULT NULL,
    `email` VARCHAR(60) DEFAULT NULL,
    PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Afterwords in anyform XML file set dbtable = "#__anyform_data"

2. AnyForm does not support this.
Title: Re: How to create form using Any Form
Post by: komang on February 20, 2018, 07:29:54
Hi Datahell,

I tried this but it can't save data to database. I created the database table (see the attachment) then I set dbtable = "#__anyform_data" on the sampel.xml but I am not sure the way I set the dbtable is right. I learned XML at https://www.xml.com/pub/a/2001/02/07/trxml9.html.

please check the sampel.xml below.

The form can be access at https://finteku.com/diskusi/apakah-perkembangan-fintek-bisa-mengancam.html


Sorry, I don't understand about XML.

Thank you

Regards,

Komang

<form>
   <title overwrite="1" hide="1">Sample form</title>
   <emailtitle>Submitted sample form</emailtitle>
   <description><![CDATA[
      <p><strong>AnyForm</strong> is a plugin that allows you to display and process custom HTML forms within Elxis 4.x content items.
      This sample form contains all types of elements AnyForm supports in order to use it as a sample for your own forms.   
      Created by Ioannis Sannos &copy; 2008-2017 <a href="https://www.isopensource.com" title="IOS - Web services and software">Is Open Source</a>.
      All rights reserved.</p>
      ]]>
   </description>
   <onsuccess><![CDATA[
      <h3>Success!</h3>
       <p class="anyf_success">This is a sample text that is being displayed after successfully submitting the form. Plugin <strong>AnyForm</strong> by isopensource.com
       allows you to easily change this message by editing the form info on XML file.</p> ]]>
      
   </onsuccess>
   <action>email</action>
   <email></email>
   <dbtable dbtable = "#__anyform_data"></dbtable>
   <items>
      <item type="openfieldset" label="PERSONAL_INFORMATION" />
      <item type="text" name="name" label="FIRSTNAME" required="1" default="{FIRSTNAME}" tip=""></item>
      <item type="text" name="surname" label="LASTNAME" required="1" default="{LASTNAME}" tip=""></item>
      <item type="text" name="phone" label="TELEPHONE" required="1" default="" tip=""></item>
      <item type="email" name="email" label="EMAIL" required="1" default="{EMAIL}" tip=""></item>
      <item type="radio" name="gender" label="Gender" default="0" tip="">
         <option value="0">Male</option>
         <option value="1">Female</option>
      </item>
      <item type="range" name="age" label="AGE" first="0" last="120" step="1" default="30" tip=""></item>
      <item type="closefieldset" />
      <item type="openfieldset" label="Travel information" />
      <item type="date" name="date" label="DATE" required="1" default="{TOMORROW}" tip="" />
      <item type="closefieldset" />
      <item type="openfieldset" />
      <item type="norobot" name="notrobot" label="" default="" tip="" />
      <item type="button" name="sbt" label="" default="SUBMIT" button_type="submit" fieldboxclass="" />
      <item type="closefieldset" />
   </items>
</form>

(http://any form 5.PNG)
Title: Re: How to create form using Any Form
Post by: webgift on February 20, 2018, 09:41:20
'action' field should be changed for sure. Use 'database' or
'emaildatabase' instead of 'email'.

I think that dbtable should be set like:

<dbtable>#__anyform_data</dbtable>
Title: Re: How to create form using Any Form
Post by: komang on February 20, 2018, 10:07:18
Hi webgift,

yess, it works...

I tried <dbtable>#__anyform_data</dbtable> but I forget to change the action field.

Thank you so much
Title: Re: How to create form using Any Form
Post by: webgift on February 20, 2018, 15:48:04
You're welcome @komang!