Call to a member function add() on a non-object
/home/bankofel/public_html/application/blocks/external_form/form/controller/contact_form_popup.php
{publicfunction action_contact_us($bID=false){$captcha= Core::make("captcha");if(!$captcha->check()){$this->error->add('Incorrect Captcha');}

Ok, so the issue is that you don't have an error object to add an error to, the captcha is incorrect. This code should really be inside of your if, not before it, otherwise it's probably getting called on the second form submit.

<?php
namespace Application\Block\ExternalForm\Form\Controller;
use Concrete\Core\Controller\AbstractController;
use Core;class ContactFormPopup extends AbstractController
{publicfunction action_contact_us($bID=false){if($this->bID==$bID){$captcha= Core::make("captcha");if(!$captcha->check()){$this->error->add('Incorrect Captcha');}foreach($_POSTas$key=>$value){if($key!=="send"){$kkey=str_replace('_',' ',$key);if(is_array($value)){$value=implode(', ',$value);}if($key=='Contact_Date_m'||$key=='Contact_Date_a'||$key=='submit'){continue;}elseif($key=='Contact_Date_dt'){$addbody.='<strong>Contact Date</strong>: '.date('m-d-Y',strtotime($value)).'<br/><br/>';}elseif($key=='Contact_Date_h'){$addbody.='<strong>Contact Time</strong>: '.$_POST['Contact_Date_h'].':'.$_POST['Contact_Date_m'].' '.$_POST['Contact_Date_a'].'<br/><br/>';}else{$addbody.='<strong>'.$kkey.'</strong>: '.$value.'<br/><br/>';}}}//echo $addbody;//$addbody.='<strong>Submit this form to</strong> .';$body=$addbody;$mh= Loader::helper('mail');$mh->to('[email protected]');$mh->from('[email protected]');$mh->setSubject('Contact form');$mh->setBodyHtml($body);$mh->sendMail();$this->set('response', t('Thank you. We will be in touch with you as requested.'));}}publicfunction view(){$this->set('message', t('This is just an example of how a custom form works.'));}}

<?php
namespace Application\Block\ExternalForm\Form\Controller;
use Concrete\Core\Controller\AbstractController;
use Core;class ContactFormPopup extends AbstractController
{publicfunction action_contact_us($bID=false){if($this->bID==$bID){$captcha= Core::make("captcha");if($captcha->check()){foreach($_POSTas$key=>$value){if($key!=="send"){$kkey=str_replace('_',' ',$key);if(is_array($value)){$value=implode(', ',$value);}if($key=='Contact_Date_m'||$key=='Contact_Date_a'||$key=='submit'){continue;}elseif($key=='Contact_Date_dt'){$addbody.='<strong>Contact Date</strong>: '.date('m-d-Y',strtotime($value)).'<br/><br/>';}elseif($key=='Contact_Date_h'){$addbody.='<strong>Contact Time</strong>: '.$_POST['Contact_Date_h'].':'.$_POST['Contact_Date_m'].' '.$_POST['Contact_Date_a'].'<br/><br/>';}else{$addbody.='<strong>'.$kkey.'</strong>: '.$value.'<br/><br/>';}}}//echo $addbody;//$addbody.='<strong>Submit this form to</strong> .';$body=$addbody;$mh= Loader::helper('mail');$mh->to('[email protected]');$mh->from('[email protected]');$mh->setSubject('Contact form');$mh->setBodyHtml($body);$mh->sendMail();$this->set('response', t('Thank you. We will be in touch with you as requested.'));}else{$error= Core::make('helper/validation/error');$error->add(t('Incorrect Captcha'));$this->set('error',$error);}}}publicfunction view(){$this->set('message', t('This is just an example of how a custom form works.'));}}

<?php
namespace Application\Block\ExternalForm\Form\Controller;
use Concrete\Core\Controller\AbstractController;
use Core;class ContactFormPopup extends AbstractController
{publicfunction action_contact_us($bID=false){if($this->bID==$bID){$captcha= Core::make("captcha");if($captcha->check()){foreach($_POSTas$key=>$value){if($key!=="send"){$kkey=str_replace('_',' ',$key);if(is_array($value)){$value=implode(', ',$value);}if($key=='Contact_Date_m'||$key=='Contact_Date_a'||$key=='submit'){continue;}elseif($key=='Contact_Date_dt'){$addbody.='<strong>Contact Date</strong>: '.date('m-d-Y',strtotime($value)).'<br/><br/>';}elseif($key=='Contact_Date_h'){$addbody.='<strong>Contact Time</strong>: '.$_POST['Contact_Date_h'].':'.$_POST['Contact_Date_m'].' '.$_POST['Contact_Date_a'].'<br/><br/>';}else{$addbody.='<strong>'.$kkey.'</strong>: '.$value.'<br/><br/>';}}}//echo $addbody;//$addbody.='<strong>Submit this form to</strong> .';$body=$addbody;$mh= Loader::helper('mail');$mh->to('[email protected]');$mh->from('[email protected]');$mh->setSubject('Contact form');$mh->setBodyHtml($body);$mh->sendMail();$this->set('response', t('Thank you. We will be in touch with you as requested.'));}else{$error= Core::make('helper/validation/error');$error->add(t('Incorrect Captcha'));$this->set('error',$error);}}}publicfunction view(){$this->set('message', t('This is just an example of how a custom form works.'));}}

I am wondering if maybe an AJAX submission would be better since this is in a modal? Problem is that on submit, the modal is closing before the captcha has a chance to validate. Any grand ideas about this?