Can’t add new element to Quform PHP

Home Forums Quform PHP Can’t add new element to Quform PHP

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #35247
    tomf2468a
    Participant

    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 31

    I 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

    #35248
    tomf2468a
    Participant

    OP 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">

    #35251
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35255
    tomf2468a
    Participant

    Thanks! I finally saw that (after looking at that code 10 time) and was coming here to say “ignore that stupid user mistake” 😉

    #35256
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy