Answers.Body: <p>Maybe it is not connected to your issue, but if you implement a form, it supposed to be inside a <code>Form</code> directory, and the class name should follow this (has to contain <code>_Form_</code>). In your case the class name contains the <code>_Page_</code> string which is strange. I would like to suggest you to <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-form" rel="nofollow noreferrer">generate</a> the basics of your form with the <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/" rel="nofollow noreferrer"><code>civix</code> tool</a>. After the file generation you can check that the dummy form works well or not. If it works well, you can start to modify the dummy code.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-12T18:50:52.653Z
Answers.Text: Thank you! I am stupid... I put it in wrong location... I had created a page and I transform it to the form. It is neccessery that the form is in form directory. And also civix will help with this.
Answers.UserDisplayName: vitius
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-12T14:06:49.053Z
Answers.LastActivityDate: 2022-02-12T14:06:49.053Z
Answers.UserDisplayName: akosgarai
Answers.Body: <p>In preprocess/postprocess/buildquickform, you should call the parent, i.e. your class should be:</p>
  <pre><code>class CRM_JosiahVenture_Page_RolePrimaryAlert extends CRM_Core_Form {
  
    public function preProcess() {
      parent::preProcess(); // &lt;-- ************ add this
    }
  
    public function buildQuickForm() {
      parent::buildQuickForm();  // &lt;-- ************ and this
      $this-&gt;add('text', 'my_text_field', ts('Enter Some Text'));
    }
  
    public function addRules() {
      $this-&gt;addFormRule(array('CRM_Example_Form', 'myRules'));
    }
  
    public static function myRules($values) {
      $errors = array();
      if ($values['foo'] != 'abc') {
        $errors['foo'] = ts('You entered the wrong text!');
      }
      return empty($errors) ? TRUE : $errors;
    }
  
    public function postProcess() {
      parent::postProcess();  // &lt;-- ************ and this
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-11T20:35:58.953Z
Answers.Text: What do you mean parent? Do you mean "CRM_Core_Form" from which I extend? Can be more specific please? I want seperate page where preprocess can be empty now, in buildquickform i want 1 input field and in postprocess I want call api3. The most simple form from which I can understand how it works.
  I also try make copy of form, which extend "CRM_Core_Form" and I got the same error.
Answers.UserDisplayName: vitius
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-11T20:40:24.813Z
Answers.Text: I'll update my answer more fully.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-11T20:48:06.133Z
Answers.Text: Thanks, but this not help :/ Still I get same error..
Answers.UserDisplayName: vitius
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-11T17:14:40.867Z
Answers.LastActivityDate: 2022-02-11T20:42:06.330Z
Answers.LastEditDate: 2022-02-11T20:42:06.330Z
Answers.UserDisplayName: Demerit
Body: <p>I want to create page with form via my custom extension. I find this page in documentation: <a href="https://docs.civicrm.org/dev/en/latest/framework/quickform/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/framework/quickform/</a>
  But when I create a class according to the documentation, I get this error:</p>
  <pre><code>Error: Call to a member function setName() on string in CRM_Core_Form-&gt;__construct() (line 271 of /var/www/mvp1/web/sites/all/modules/civicrm/CRM/Core/Form.php).
  </code></pre>
  <p>My class:</p>
  <pre><code>class CRM_JosiahVenture_Page_RolePrimaryAlert extends CRM_Core_Form {
  
    public function preProcess() {
    }
  
    public function buildQuickForm() {
      $this-&gt;add('text', 'my_text_field', ts('Enter Some Text'));
    }
  
    public function addRules() {
      $this-&gt;addFormRule(array('CRM_Example_Form', 'myRules'));
    }
  
    public static function myRules($values) {
      $errors = array();
      if ($values['foo'] != 'abc') {
        $errors['foo'] = ts('You entered the wrong text!');
      }
      return empty($errors) ? TRUE : $errors;
    }
  
    public function postProcess() {
    }
  }
  </code></pre>
  <p>My xml file:</p>
  <pre><code>&lt;item&gt;
      &lt;path&gt;civicrm/RolePrimary&lt;/path&gt;
      &lt;page_callback&gt;CRM_JosiahVenture_Page_RolePrimaryAlert&lt;/page_callback&gt;
      &lt;title&gt;CustomActivity&lt;/title&gt;
      &lt;access_arguments&gt;access CiviCRM&lt;/access_arguments&gt;
    &lt;/item&gt;
  </code></pre>
  <p>Tpl file is empty for now.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-12T18:33:33.397Z
Comments.Text: @PradeepNayak yes.
Comments.UserDisplayName: vitius
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-11T22:33:23.050Z
Comments.Text: Are you using url civicrm/RolePrimary?reset=1&action=add ?
Comments.UserDisplayName: Pradeep Nayak
Tags: <extension><quickform><custom>
Title: Can't create quickform via CRM_Core_Form in my custom extension
ThreadText: # Can't create quickform via CRM_Core_Form in my custom extension
  
  (Asked by: username_0 on 2022-02-11)
  
  I want to create page with form via my custom extension. I find this page in documentation: <https://docs.civicrm.org/dev/en/latest/framework/quickform/>
  But when I create a class according to the documentation, I get this error:
  
  ```
  Error: Call to a member function setName() on string in CRM_Core_Form->__construct() (line 271 of /var/www/mvp1/web/sites/all/modules/civicrm/CRM/Core/Form.php).
  
  ```
  
  My class:
  
  ```
  class CRM_JosiahVenture_Page_RolePrimaryAlert extends CRM_Core_Form {
  
    public function preProcess() {
    }
  
    public function buildQuickForm() {
      $this->add('text', 'my_text_field', ts('Enter Some Text'));
    }
  
    public function addRules() {
      $this->addFormRule(array('CRM_Example_Form', 'myRules'));
    }
  
    public static function myRules($values) {
      $errors = array();
      if ($values['foo'] != 'abc') {
        $errors['foo'] = ts('You entered the wrong text!');
      }
      return empty($errors) ? TRUE : $errors;
    }
  
    public function postProcess() {
    }
  }
  
  ```
  
  My xml file:
  
  ```
  <item>
      <path>civicrm/RolePrimary</path>
      <page_callback>CRM_JosiahVenture_Page_RolePrimaryAlert</page_callback>
      <title>CustomActivity</title>
      <access_arguments>access CiviCRM</access_arguments>
    </item>
  
  ```
  
  Tpl file is empty for now.
  
  **Tags:** extension, quickform, custom
  
  > **Comments:**
  > **username_1**: Are you using url civicrm/RolePrimary?reset=1&action=add ?  
  > **username_0**: @username_1 yes.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-02-12. Score: 2 | Accepted answer
  
  Maybe it is not connected to your issue, but if you implement a form, it supposed to be inside a `Form` directory, and the class name should follow this (has to contain `_Form_`). In your case the class name contains the `_Page_` string which is strange. I would like to suggest you to [generate](https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-form) the basics of your form with the [`civix` tool](https://docs.civicrm.org/dev/en/latest/extensions/civix/). After the file generation you can check that the dummy form works well or not. If it works well, you can start to modify the dummy code.
  
  > **Comments:**
  > **username_0**: Thank you! I am stupid... I put it in wrong location... I had created a page and I transform it to the form. It is neccessery that the form is in form directory. And also civix will help with this.  
  
  ---
  
  ### Answer by username_3 on 2022-02-11. Score: 0
  
  In preprocess/postprocess/buildquickform, you should call the parent, i.e. your class should be:
  
  ```
  class CRM_JosiahVenture_Page_RolePrimaryAlert extends CRM_Core_Form {
  
    public function preProcess() {
      parent::preProcess(); // <-- ************ add this
    }
  
    public function buildQuickForm() {
      parent::buildQuickForm();  // <-- ************ and this
      $this->add('text', 'my_text_field', ts('Enter Some Text'));
    }
  
    public function addRules() {
      $this->addFormRule(array('CRM_Example_Form', 'myRules'));
    }
  
    public static function myRules($values) {
      $errors = array();
      if ($values['foo'] != 'abc') {
        $errors['foo'] = ts('You entered the wrong text!');
      }
      return empty($errors) ? TRUE : $errors;
    }
  
    public function postProcess() {
      parent::postProcess();  // <-- ************ and this
    }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: What do you mean parent? Do you mean "CRM_Core_Form" from which I extend? Can be more specific please? I want seperate page where preprocess can be empty now, in buildquickform i want 1 input field and in postprocess I want call api3. The most simple form from which I can understand how it works. I also try make copy of form, which extend "CRM_Core_Form" and I got the same error.  
  > **username_3**: I'll update my answer more fully.  
  > **username_0**: Thanks, but this not help :/ Still I get same error..  
  
  ---
  
  