Page 1 of 1

How to make a field required on Affiliate Form

Posted: Fri Sep 13, 2013 5:18 am
by BellaBella
Hello! I've been getting the hang of this, but I am recently stuck on this one annoying bit. I have no idea where to find the code to change a field to being required.

I want to make "Website" required on my Affiliate Registration Form, just the same as First Name, Last Name, etc. How do I do this? Where do I go to find the code to edit? But first, is it even possible?
Image

Please help ???

Re: How to make a field required on Affiliate Form

Posted: Sat Sep 14, 2013 12:17 am
by BellaBella
Help please?

Re: How to make a field required on Affiliate Form

Posted: Sat Sep 14, 2013 2:43 am
by ocmta
First of all, required or not, openCart does not even save affiliate website information. You'll need a fix like the one in the attachment for that.

Then, the easier way to make it required would by editing the template and adding some javascript. Open catalog/view/theme/default/template/affiliate/register.php, find this:

Code: Select all

<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
and replace with this:

Code: Select all

<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" onsubmit="javascript:if($('input[name=\'website\']').val().length < 4){alert('Website required!');return false;}">
Also, to get a star symbol, find:

Code: Select all

<td><?php echo $entry_website; ?></td>
and replace with:

Code: Select all

<td><span class="required">*</span> <?php echo $entry_website; ?></td>
Now, this won't give you similar processing as with other required fields, similar processing would involve adding or changing a lot of code in several different files. With the code above form just won't submit without website.

Re: How to make a field required on Affiliate Form

Posted: Thu Sep 26, 2013 12:22 am
by BellaBella
ocmta wrote:First of all, required or not, openCart does not even save affiliate website information. You'll need a fix like the one in the attachment for that.

Then, the easier way to make it required would by editing the template and adding some javascript. Open catalog/view/theme/default/template/affiliate/register.php, find this:

Code: Select all

<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
and replace with this:

Code: Select all

<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" onsubmit="javascript:if($('input[name=\'website\']').val().length < 4){alert('Website required!');return false;}">
Also, to get a star symbol, find:

Code: Select all

<td><?php echo $entry_website; ?></td>
and replace with:

Code: Select all

<td><span class="required">*</span> <?php echo $entry_website; ?></td>
Now, this won't give you similar processing as with other required fields, similar processing would involve adding or changing a lot of code in several different files. With the code above form just won't submit without website.
Ocmta, by similar processing do you mean, it won't show up when I receive the form or that it won't remain in my Admin Affiliate panel? If it's the latter, I can deal with that. I would just keep an off site database of the list of affiliate/websites. I just wanted a way to be able to view the site to ensure my affiliate banners won't be placed on any websites that violate my policies (like adult sites). Thanks so much for the info!

Re: How to make a field required on Affiliate Form

Posted: Thu Sep 26, 2013 12:35 am
by ocmta
It will show up in the form and in admin (with the fix i attached in previous message). By similar processing i just mean error processing - it if they try to submit the form with empty website, it just won't submit, while with other fields, it will submit, but will not save and will reload with error messages under input boxes.

Re: How to make a field required on Affiliate Form

Posted: Thu Sep 26, 2013 10:41 pm
by BellaBella
ocmta wrote:It will show up in the form and in admin (with the fix i attached in previous message). By similar processing i just mean error processing - it if they try to submit the form with empty website, it just won't submit, while with other fields, it will submit, but will not save and will reload with error messages under input boxes.
Thank you so much ocmta! You've solved my issue! I will be purchasing your Customer & Affiliate Combined extension when we get closer to launching. You're an angel! :)