• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Form Name attribute not generating - code fix

Form Name attribute not generating - code fix 16 years 11 months ago #4430

  • partic
  • partic's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I've been working on a form which is an order form that needs to validate whether all the quantity fields on the form are not zero to see that the order has at least one item ordered. To do that I've created some javascript, but to get it working, I needed to call that validation function onto the form name as an attribute in the submit button:
<input type="submit" onclick="validate(orderform);" id="submit" name="form[submit]" value="Submit"/>

However, I've found that there's no form name variable put in when the RSForm is generated for display:
<form id="userForm" action="" enctype="multipart/form-data" method="post">

So, to fix it, some tweaks to components/com_rsform/controller/functions.php are needed:

On Line 720, change:
$q="select FormLayout, ScriptDisplay from $RSadapter->tbl_rsform_forms where FormId='$formId'";
to
$q="select FormLayout, ScriptDisplay, [b]FormName[/b] from $RSadapter->tbl_rsform_forms where FormId='$formId'";
This adds the formname to the query.

Next at Line 728 (or thereabouts) add this to tidy up the form name and create the string:
$formName=stripslashes($r['FormName']);

Finally around line 780 change:
$formLayout = '<form method="post"  id="userForm" enctype="multipart/form-data" action="">'.$formLayout.'</form>';
to
$formLayout = '<form method="post" [b]name="'.$formName.'"[/b] id="userForm" enctype="multipart/form-data" action="">'.$formLayout.'</form>';

This then adds the name="<formname>" value into the form tag, and you can then call it for extra validation.

The final step is in your form, and the formname is the form name field when you create the form. It's probably advisable that you keep this now shorter and not having spaces in it too.
Last Edit: 16 years 5 months ago by octavian.
The administrator has disabled public write access.

Re:Form Name attribute not generating - code fix 16 years 6 months ago #6098

  • Mr.Jinx
  • Mr.Jinx's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Thank you for sharing this!
Exactly what I was looking for.

Is the missing name tag a small bug?
The administrator has disabled public write access.

Re:Form Name attribute not generating - code fix 16 years 3 months ago #7232

  • jgodek
  • jgodek's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
my files look nothing like that.
im using Installed version: 1.1.0
and my function.php has none of that code.

Any other fixes for this? Strange thing to have in the code anyway?
The administrator has disabled public write access.

Re:Form Name attribute not generating - code fix 14 years 11 months ago #11078

  • Mr.Jinx
  • Mr.Jinx's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Because the form tag 'name' is still not included in the latest release, here is how to change this. Works for the latest version 10.06.2010 - Rev 29.

Open components/com_rsform/controller/functions.php

Find (around line 808):
$db->setQuery("SELECT `FormId`, `FormLayout`, `ScriptDisplay`, `ErrorMessage` FROM #__rsform_forms WHERE FormId='".$formId."' AND `Published`='1'");
$r = $db->loadAssoc();
 
if (empty($r['FormId'])) return JText::_('_NOT_EXIST');
 
$scriptDisplay = $r['ScriptDisplay'];
$formLayout = $r['FormLayout'];
$errorMessage = $r['ErrorMessage'];

Replace with:
$db->setQuery("SELECT `FormId`, `FormLayout`, `ScriptDisplay`, `FormName`, `ErrorMessage` FROM #__rsform_forms WHERE FormId='".$formId."' AND `Published`='1'");
$r = $db->loadAssoc();
 
if (empty($r['FormId'])) return JText::_('_NOT_EXIST');
 
$scriptDisplay = $r['ScriptDisplay'];
$formLayout = $r['FormLayout'];
$formName = stripslashes($r['FormName']);
$errorMessage = $r['ErrorMessage'];

Find (around line 866):
$formLayout = '<form method="post" id="userForm" enctype="multipart/form-data" action="'.$u.'">'.$formLayout.'</form>';

Replace with:
$formLayout = '<form method="post" name="'.$formName.'" id="userForm" enctype="multipart/form-data" action="'.$u.'">'.$formLayout.'</form>';

Hmm, too bad the CODE function doesn't work correctly on this forum so the above samples are all messed up. But at least you know where to look.
Last Edit: 14 years 11 months ago by Mr.Jinx.
The administrator has disabled public write access.

Re:Form Name attribute not generating - code fix 14 years 10 months ago #11320

  • Mr.Jinx
  • Mr.Jinx's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Here is a nice fix provided by RSJoomla! support (thnx Andrei). This way you don't need to edit the sourcecode.

Add the following code to the 'Scripts called on form display':
$formLayout = str_replace('method="post"','method="post" name="form_name"', $formLayout);

Just replace 'form_name' with whatever you like.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!