support

Author Topic: Override or hook into AForm and AHtml  (Read 1225 times)

Offline yonghan79

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +21/-0
    • View Profile
Override or hook into AForm and AHtml
« on: November 12, 2024, 06:06:48 AM »
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.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2068
  • Karma: +327/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Override or hook into AForm and AHtml
« Reply #1 on: November 12, 2024, 10:18:19 AM »
What mean custom html field?
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline yonghan79

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +21/-0
    • View Profile
Re: Override or hook into AForm and AHtml
« Reply #2 on: November 12, 2024, 10:44:06 AM »
i mean like custom captcha

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2068
  • Karma: +327/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Override or hook into AForm and AHtml
« Reply #3 on: November 13, 2024, 06:07:29 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:

Code: [Select]
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

Offline yonghan79

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +21/-0
    • View Profile
Re: Override or hook into AForm and AHtml
« Reply #4 on: November 13, 2024, 11:04:28 AM »
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.

 

Powered by SMFPacks Social Login Mod