Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

Form Name attribute not generating - code fix

Welcome, Guest
Username Password: Remember me

Form Name attribute not generating - code fix
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Form Name attribute not generating - code fix

Form Name attribute not generating - code fix 3 years, 5 months ago #4430

  • partic
  • 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: 2 years, 12 months ago by octavian.

Re:Form Name attribute not generating - code fix 3 years, 1 month ago #6098

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

Is the missing name tag a small bug?

Re:Form Name attribute not generating - code fix 2 years, 9 months ago #7232

  • jgodek
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
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?

Re:Form Name attribute not generating - code fix 1 year, 6 months ago #11078

  • Mr.Jinx
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
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: 1 year, 6 months ago by Mr.Jinx.

Re:Form Name attribute not generating - code fix 1 year, 5 months ago #11320

  • Mr.Jinx
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
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.

Re:Form Name attribute not generating - code fix 6 hours, 1 minute ago #0

Hello,
This is an automatically generated message.
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 wish to receive our 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: http://www.rsjoomla.com/support-policy.html.

Thank You!
PLEASE NOTE: This topic is NOT locked and you can add replies to it. Other users are free to reply as well. This message has been generated by a bot and has no effect on the topic whatsoever.
  • Page:
  • 1
Moderators: alex, alexp, octavian, bogdanc, andreic
Time to create page: 2.12 seconds
Feedback