Home › Forums › Quform PHP › Can’t add new element to Quform PHP
- This topic has 4 replies, 2 voices, and was last updated 1 year, 9 months ago by Ally.
- AuthorPosts
- March 20, 2023 at 10:36 pm #35247tomf2468aParticipant
Hello,
Brand new user of this software. I am trying to add an additional element to the standard form (a not required phone number field). But, I keep getting both an error and a failed email (nothing sent). Works perfect without the mods.This is the error I’m getting with the phone number field:
Warning: Undefined variable $phone in /homepages/36/d833424105/htdocs/quform/process.php on line 221
Fatal error: Uncaught TypeError: Quform::addElement(): Argument #1 ($element) must be of type Quform_Element, null given, called in /homepages/36/d833424105/htdocs/quform/process.php on line 221 and defined in /homepages/36/d833424105/htdocs/quform/lib/Quform.php:31
Stack trace:
#0 /homepages/36/d833424105/htdocs/quform/process.php(221): Quform->addElement()
#1 {main}
thrown in /homepages/36/d833424105/htdocs/quform/lib/Quform.php on line 31I added this after the email and before the message to my contact page html
<!-- Begin Text input element --> <div class="quform-element quform-element-text"> <div class="quform-spacer"> <label for="phone">Phone Number (Optional) </label> <div class="quform-input"> <input id="phone" type="text" name="phone" /> </div> </div> </div> <!-- End Text input element -->
I added this to the process.php
/** * Configure the phone element * Filters: Trim * Validators: Not required */ $name = new Quform_Element('phone', 'Phone Number (Optional)'); $name->addFilter('trim'); /* $name->addValidator(''); */ $form->addElement($phone);
I’m only semi strong modifying PHP, but I’m wondering if I need to modify Quform > lib > Quform.php ??
public function addElement(Quform_Element $element) { $element->setForm($this); $this->_elements[$element->getName()] = $element; return $this; }
If so, an example would be great!
Tom
March 20, 2023 at 10:42 pm #35248tomf2468aParticipantOP again, I forgot to mention… I did check and believe I am editing the correct process file
<form class="quform" action="quform/process.php" method="post" enctype="multipart/form-data">
March 21, 2023 at 8:37 am #35251AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 21, 2023 at 4:08 pm #35255tomf2468aParticipantThanks! I finally saw that (after looking at that code 10 time) and was coming here to say “ignore that stupid user mistake” 😉
March 22, 2023 at 7:52 am #35256AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.