AbanteCart Development > Development Help Needed

Override or hook into AForm and AHtml

(1/1)

yonghan79:
Hi, core developers,

i want to ask if it's possible to override AForm and AHtml and then use the overriden as the default one to be used by cart?

I would like to add a custom HTML field that core code can access as well, such as the default contact us form.

Thanks.

abolabo:
What mean custom html field?

yonghan79:
i mean like custom captcha

abolabo:

--- Quote from: yonghan79 on November 12, 2024, 10:44:06 AM ---i mean like custom captcha

--- End quote ---

please take a note we added new property for all html-elements of form. it's a "template"
Since v1.4.1 you can set your own tpl file for captcha element inside your controller.

OR...
 you can create your own element class and place into your_extension/core directory:


--- Code: ---class YourCustomCaptchaHtmlElement extends HtmlElement
{
    public function getHtml()
    {
        $data = [
            'id'       => $this->element_id,
            'name'     => $this->name,
...
        ];

        $this->view->batchAssign($data);
        return $this->view->fetch('form/your_captcha.tpl');
    }
}
--- End code ---

Then look at line https://github.com/abantecart/abantecart-src/blob/master/public_html/core/engine/html.php#L899
You custom class will be called from it. Just use correct "type" array key ;-)
P.S. Do not forget include file with your class inside main.php of your extension.

yonghan79:
How do we allow the custom captcha html element to be available as selection for admin to choose from the field type list? so it is loaded in the contact us form.

Navigation

[0] Message Index

Go to full version
Powered by SMFPacks Social Login Mod