Forums

where/how to enter my old onSubmit in CFv4?

gemlog 23 Mar, 2012
In the previous version I had only the following text in 'Core/View Form Settings' in the field labeled 'Form tag attachment:something like onSubmit()':

onSubmit="return checkform()"

My checkform() function did whatever and returned either TRUE or FALSE and the onSubmit continued or not. I have the same js loaded as before using 'On Load'/'Load CSS'.

How do I accomplish this in the new version? Sorry if I'm being a bother, but I can't see where the docs are. I won't be offended if you just link me to the docs and say rtfm -- honest!
GreyHead 23 Mar, 2012
Hi gemlog,

The Form Tag attachment box is still on the form General tab; click the Form Name link in the Forms Manager to get to it.

But it would be neater not to use that but to add it to your script in the Load JS box.
window.addEvent('domready', function() {
  $('chronoform_my_form_name').addEvent('submit', checkForm());
});
I'm not sure if that should be checkForm() or checkForm but you'll soon find out.

Bob
gemlog 23 Mar, 2012
Thanks, I didn't even think to look in the old place, duh. But, I'll put it with the rest of my js as that makes more sense in the new schema.
gemlog 23 Mar, 2012
I put this into a js block, but it comes up blank.
var formname = '<?php echo $MyForm->formrow->name; ?>';

I see '' in the page source and even threw in an alert(formname) right after and it shows up blank.
I did try to go back to the old way, but nothing I put into the 'Form tag attachment' field will save.
I need one way or the other, because after I have this working again, it will be duplicated over and over ad hoc by those who admin the site using different form names.
GreyHead 24 Mar, 2012
Hi gemlog,

$MyForm doesn't work in CFv4. The equivalent is the $form->data array.

Bob
gemlog 24 Mar, 2012
> The equivalent is the $form->data array.

Gotcha, $form->data['chronoform'] , thanks!
GreyHead 25 Mar, 2012
Hi gemlog,

I rushed my answer a bit. $form is (more or less) the equivalent of $MyForm; the $form->data array only has the data part in it. I think that $from->name will give you the form name if you need it. If in doubt echo out the whole $form object to see exactly what is what - but be warned it can be very big.

Bob
This topic is locked and no more replies can be posted.