Do you like AbanteCart? Please rate AbanteCart or share your experience with other eCommerce entrepreneurs. Go to Softaculous rating page to add your rating or write a review

Override or hook into AForm and AHtml

Started by yonghan79, November 12, 2024, 06:06:48 AM

Previous topic - Next topic

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

"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

yonghan79


abolabo

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

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:

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');
    }
}


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.

"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

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.

Forum Rules Code of conduct
AbanteCart.com 2010 -