Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for Phone Does not Proccess #3

Closed
2a5A1Ghu1 opened this issue Nov 11, 2016 · 2 comments
Closed

Option for Phone Does not Proccess #3

2a5A1Ghu1 opened this issue Nov 11, 2016 · 2 comments

Comments

@2a5A1Ghu1
Copy link

2a5A1Ghu1 commented Nov 11, 2016

I added a field for phone and it did not work so I tried adding the right(hopefully) code so it could be processed and sent did not work.

index.php
<div class="form-group" id="phone-field"> <label for="form-phone" class="col-lg-2 control-label"><?php echo $config->get('fields.phone'); ?></label> <div class="col-lg-10"> <input type="phone" class="form-control" id="form-phone" name="form-phone" placeholder="<?php echo $config->get('fields.phone'); ?>" required> </div> </div>

contactform.js(sorry for some reason this code is being escaped by github but is showing up correctly)

if (data.errors.phone) {
var email = document.querySelector('input[name="form-phone"]').parentNode,
error;

                this.addClass(phone, 'has-error');
                error = this.template(
                    '<span class="help-block">{report}</span>', {
                    report: data.errors.phone
                });

                phone.insertAdjacentHTML('beforeend', error);
            }

config.php

'phone' => 'Phone is required',

proccess.php

errors on the line below added just below email. Throws error Undefined index: phone in /path/to/process.php on line 22
$phone = stripslashes(trim($_POST['phone']));

if (empty($phone)) { $errors['phone'] = $config->get('messages.validation.emptyphone'); }

<p><strong>{$config->get('fields.phone')}:</strong> {$phone}</p>

Any help adding a phone field and maybe in the future some type of recapatcha validation would be awesome. Thanks in advance!

@pinceladasdaweb
Copy link
Owner

@buddilla

See the example I created, I just tested and it's working ok.: https://github.com/pinceladasdaweb/Ajax-Contact-Form/tree/additional-fields

@2a5A1Ghu1
Copy link
Author

2a5A1Ghu1 commented Nov 12, 2016

Thank you, now I just have to integrate it into uikit and I should be set!!! Thank god I am doing a full rewrite of a single pager site that used your older code. So this should be easier. Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants