Q: How do I remove registration form fields?
5 posts
• Page 1 of 1
Q: How do I remove registration form fields?
Q: How do I remove registration form fields? I try to remove them from the template but an error still shows.
A:
Form fields in OpenCart use php-based error handling. This means that if you remove a field from the template, the php code still looks for that field. If it doesn't find a value for it, it throws an error.
For non-required form fields like fax, company, and address_2, you can simply remove them from the tpl and they won't be missed.
But to properly remove a required form field, you need all the pieces to be removed. At this time, there are 3 spots where people can register. "account/register", "checkout/register", and "checkout/guest". OpenCart needs to work on combining the registration/checkout area to combine all into one step. The account and checkout system needs a bit of an overhaul to be simplified.
Anyway, to make the necessary changes... Determine which field you want to remove.
For this example, I will be removing the "telephone" field.
(v1.5.1)
1. Edit the first template file to remove the actual field from the html:
2. FIND and REMOVE the form field and surrounding table code. You should be able to follow the pattern of the file based on the tabbing.
3. Now you need to EDIT the controller file to remove the error checking:
4. FIND and REMOVE the validation code. All validation is done in the "validate" function towards the bottom. Find and remove the following:
That completes the necessary changes for the account/register step.
5. EDIT the checkout/register template file:
6. FIND and REMOVE the actual form field:
6. (a) FIND the closing </form> tag and BEFORE, insert:
7. EDIT the associated controller.
8. FIND and REMOVE the validation check:
That completes the necessary changes for the checkout/register step.
9. EDIT the checkout/guest template file:
10. FIND and REMOVE the actual form field:
10. (a) FIND the closing </form> tag and BEFORE, insert:
11. EDIT the associated controller.
12. FIND and REMOVE the validation check:
That completes the necessary changes for the checkout/guest step.
Now you should no longer see the telephone entry on any registration/checkout forms.
The process for 1.4.x is similar, but has code differences. If needed I will post that up but as we are working on improving this process, I am trying not to go too far back.
A:
Form fields in OpenCart use php-based error handling. This means that if you remove a field from the template, the php code still looks for that field. If it doesn't find a value for it, it throws an error.
For non-required form fields like fax, company, and address_2, you can simply remove them from the tpl and they won't be missed.
But to properly remove a required form field, you need all the pieces to be removed. At this time, there are 3 spots where people can register. "account/register", "checkout/register", and "checkout/guest". OpenCart needs to work on combining the registration/checkout area to combine all into one step. The account and checkout system needs a bit of an overhaul to be simplified.
Anyway, to make the necessary changes... Determine which field you want to remove.
For this example, I will be removing the "telephone" field.
(v1.5.1)
1. Edit the first template file to remove the actual field from the html:
- Code: Select all
catalog/view/theme/YOURTHEME/template/account/register.tpl
2. FIND and REMOVE the form field and surrounding table code. You should be able to follow the pattern of the file based on the tabbing.
- Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
<td><input type="text" name="telephone" value="<?php echo $telephone; ?>" />
<?php if ($error_telephone) { ?>
<span class="error"><?php echo $error_telephone; ?></span>
<?php } ?></td>
</tr>
3. Now you need to EDIT the controller file to remove the error checking:
- Code: Select all
catalog\controller\account\register.php
4. FIND and REMOVE the validation code. All validation is done in the "validate" function towards the bottom. Find and remove the following:
- Code: Select all
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
That completes the necessary changes for the account/register step.
5. EDIT the checkout/register template file:
- Code: Select all
catalog/view/theme/YOURTHEME/template/checkout/register.tpl
6. FIND and REMOVE the actual form field:
- Code: Select all
<span class="required">*</span> <?php echo $entry_telephone; ?><br />
<input type="text" name="telephone" value="" class="large-field" />
<br />
<br />
6. (a) FIND the closing </form> tag and BEFORE, insert:
- Code: Select all
<input type="hidden" name="telephone" value="" class="large-field" />
7. EDIT the associated controller.
- Code: Select all
catalog/controller/checkout/register.php
8. FIND and REMOVE the validation check:
- Code: Select all
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
That completes the necessary changes for the checkout/register step.
9. EDIT the checkout/guest template file:
- Code: Select all
catalog/view/theme/YOURTHEME/template/checkout/guest.tpl
10. FIND and REMOVE the actual form field:
- Code: Select all
<span class="required">*</span> <?php echo $entry_telephone; ?><br />
<input type="text" name="telephone" value="<?php echo $telephone; ?>" class="large-field" />
<br />
<br />
10. (a) FIND the closing </form> tag and BEFORE, insert:
- Code: Select all
<input type="hidden" name="telephone" value="<?php echo $telephone; ?>" class="large-field" />
11. EDIT the associated controller.
- Code: Select all
catalog/controller/checkout/guest.php
12. FIND and REMOVE the validation check:
- Code: Select all
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
That completes the necessary changes for the checkout/guest step.
Now you should no longer see the telephone entry on any registration/checkout forms.
The process for 1.4.x is similar, but has code differences. If needed I will post that up but as we are working on improving this process, I am trying not to go too far back.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18199
- Joined: Mon Jul 21, 2008 7:02 pm

Re: Q: How do I remove registration form fields?
Don't remove the input fields, change their type from "text" to "hidden". Removing them will only cause errors, as no field is passed through to the db query in the model.

If you're not living on the edge ... you're taking up too much space!
Multi-Vendor Plugin for OpenCart 1.5.1.x
Have I helped you?
-

fido-x - Posts: 1960
- Joined: Fri Jun 27, 2008 5:09 pm
- Location: Tasmania, Australia
Re: Q: How do I remove registration form fields?
Seems like this would be a good thing to add to the core at some point, so people could choose which fields to have.
-

Johnathan - Global Moderator
- Posts: 2845
- Joined: Thu Dec 17, 2009 7:08 pm
Re: Q: How do I remove registration form fields?
fido-x wrote:Don't remove the input fields, change their type from "text" to "hidden". Removing them will only cause errors, as no field is passed through to the db query in the model.
+1
- opencartArab
- Posts: 1333
- Joined: Wed Mar 31, 2010 7:31 pm
Re: Q: How do I remove registration form fields?
Tutorial updated. Inserted items 6(a) and 10(a).

If you're not living on the edge ... you're taking up too much space!
Multi-Vendor Plugin for OpenCart 1.5.1.x
Have I helped you?
-

fido-x - Posts: 1960
- Joined: Fri Jun 27, 2008 5:09 pm
- Location: Tasmania, Australia
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests























