Advertisement:

Author Topic: How can I generate a field to repeat the email in Item.form.class.php?  (Read 304 times)

Xefiron

  • Newbie
  • *
  • Posts: 32
  • Software developer - Desarrollador de software
As in line 59 in User.form.class.php is the function that generates the field to repeat the password (check_password_text) I would like to know how to implement a function that generates a field to repeat the email. I have entered the Item.form.class.php file on line 617, where the email field is created (contact_email_text), but I can not identify what should be adapted from that function to generate an email field, since when changing the data by contactEmail2 it only generates me a text field. I leave below the routes in which are the files that I mention:

  • oc-includes/osclass/frm/User.form.class.php
  • oc-includes/osclass/frm/Item.form.class.php

Thank you for your attention and I hope you can help me.
« Last Edit: March 20, 2019, 08:28:58 pm by Xefiron »

Xefiron

  • Newbie
  • *
  • Posts: 32
  • Software developer - Desarrollador de software
Well, if it serves someone I did it in the following way. In Item.form.class.php scroll down to the contact_email_text function, and after this I added the following code:

Code: [Select]
static public function check_email_text($item = null) {
            parent::generic_input_text('contactEmail2', '', null, false, false);
            return true;
        }

Later, in the script that performs the validations (With jquery Validation) add the following code within the rules, after the validation of contactEmail

Code: [Select]
contactEmail : { //This already exist
                required:true,
                email: true
            },
contactEmail2 : { //This is for the new mail re-type field
                equalTo: "#contactEmail"
            },

After, in the messages add one that corresponds to the validation of the field:

Code: [Select]
contactEmail : { //This already exist
                required:'Email is required',
                email: 'Email format is not valid'
            },
contactEmail2 : { //This is for the new mail re-type field
                equalTo: "The email entered does not match"
            },

To finish, invoke the function below your current mail field, for example:

Code: [Select]
<div class="control-group">
    <label class="control-label" for="contactEmail"><?php _e('E-mail''bender'); ?></label>
    <div class="controls">
        <?php ItemForm::contact_email_text(); ?>
    </div>
</div>
<div class="control-group">
    <label class="control-label" for="contactEmail2"><?php _e('Re-type e-mail''bender'); ?></label>
    <div class="controls">
        <?php ItemForm::check_email_text(); ?>
</div>
</div>

Note: I used Item.form.class.php since I wanted the re-type email field to be on my Item-post.php page, but it also works on the registration page since you do not really save the data from this field in the database of data. Although if you like you can do the same but within User.form.class.php for the registration page, the changes are only names.