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.