Problem with controller in custom folder

Hi,
Iā€™m trying to create a new option to the Administration Module, I do a Quick Repair and Rebuild but when I click on the new option that I created appear me an error telling me
ā€œThere is no action by that name: winmax4authenticationā€

This is my controller:

Can someone help me resolve this issue?

Best Regards,
Fairydx

Hi, welcome to the Community! :tada:

In which file is this saved?

Does you file also include all the other methods of the stock Administration controller? I suppose not. You probably want to extend the other class, something like:

class CustomAdministrationController extends AdministrationController

I think you want to be going through here

Hi pgr,
I changed my code and added that, but it stays with the same error.

There is my folder can u see whats wrong?
https://anonfiles.com/78gdLaR3o0/Administration_zip

Best Regards,
Fairydx

Youā€™re not telling me where the file is placedā€¦ I need to know that.

And if youā€™re getting an error while calling it, I need to ask, how are you calling it? What is the exact URL that is sent to the server?

Sorry, Iā€™m placing the folder on customs/Extension/modules/Administration.

And the error is when I click on the new option on the administration menu

What about the other question,

http://SuiteCRM_URL/index.php?module=Administration&action=winmax4authentication

@Fairydx
You should use directory: customs/modules/Administration
If you look at more carefully you can see it in post @pgr :

1 Like

Hi,
Now it loads but I dont have the viewā€¦

Hi, @Fairydx
I see your screenshot of code and the link (http://SuiteCRM_URL/index.php?module=Administration&action=winmax4authentication). I think that you miss: ā€˜&process=trueā€™ in the link and some else.

I added that ā€˜&process=trueā€™ and that redirect me to de administration page.

That ā€˜&process=trueā€™ is when I save the values, right?

Check both of your logs, you might be getting a PHP fatal or something in your controller code (now that it is running)

I already did that, and I donā€™t have any error

You should be using XDEBUG and a debugger to check what is happening.

Maybe no view is showing because youā€™re not returning one? Is your action intended to draw a screen, or just to run some back-end action? You might be better off doing an Ajax call in that case.

That action is to draw a screen with options to save configurations for me to use in the integration that I will create, and I think that Iā€™m returning one view :thinking:

With the XDEBUG I found out that I cant reach the view, but why?

controller.php:

public function action_winmax4authentication() {

    $this->view = 'winmax4authentication';

    ///////////////////////////////////////////////////////////////////////////////

    //// HANDLE CHANGES AFTER SUBMIT

    if(isset($_REQUEST['process']) && $_REQUEST['process'] == 'true') {

        $admin = new Administration();

        $admin->retrieveSettings();

        if (!empty($_REQUEST["url"])) {

            $admin->saveSetting("winmax4authentication", "url", html_entity_decode($_REQUEST["url"]));

        }

        if (!empty($_REQUEST["company_code"])) {

            $admin->saveSetting("winmax4authentication", "company_code", $_REQUEST["company_code"]);

        }

        if (!empty($_REQUEST["user"])) {

            $admin->saveSetting("winmax4authentication", "user", $_REQUEST["user"]);

        }

        if (!empty($_REQUEST["password"])) {

            $admin->saveSetting("winmax4authentication", "password", $_REQUEST["password"]);

        }

        header('Location: index.php?module=Administration&action=index');

    }

view.winmax4authentication.php:
<?php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

global $current_user, $sugar_config;

if (!is_admin($current_user)) sugar_die("Unauthorized access to administration.");

require_once('include/MVC/View/SugarView.php');

class Viewauthentication extends SugarView {

    public function __construct() {

        parent::SugarView();

    }

    public function preDisplay() {

        $this->dv->tpl = 'custom/modules/Administration/tpl/winmax4authentication.tpl';

    }

    public function display() {

        global $sugar_config, $mod_strings, $app_strings;

        $smarty = new Sugar_Smarty();

        $smarty->assign('MOD', $mod_strings);

        $smarty->assign('APP', $app_strings);

        $smarty->assign('config', $sugar_config['winmax4authentication']);

        $admin = new Administration();

        $admin->retrieveSettings();

        if (array_key_exists('winmax4authentication_url', $admin->settings))

            $smarty->assign('URL', $admin->settings['winmax4authentication_url']);

        if (array_key_exists('winmax4authentication_company_code', $admin->settings))

            $smarty->assign('COMPANY_CODE', $admin->settings['winmax4authentication_company_code']);

        if (array_key_exists('winmax4authentication_user', $admin->settings))

            $smarty->assign('USER', $admin->settings['winmax4authentication_user']);

        if (array_key_exists('winmax4authentication_password', $admin->settings))

            $smarty->assign('PASSWORD', $admin->settings['winmax4authentication_password']);

        $smarty->display($this->dv->tpl);
    }

}

?>

First, if this is a new XDEBUG configuration, check that your breakpoints are hitting by setting one at the beginning of index.php. Just to check itā€™s breaking when the request starts.

Then try setting a breakpoint in the GetController code that I mentioned in my post above, and see what is happening there.

How do I do that breakpoints?

That depends on which IDE youā€™re using (PHP Storm, Eclipse, VS Code, etc)

To get a debugger up and running, you can check documentation on the internet, itā€™s nothing specific to SuiteCRM. I highly recommend that you do it, it changes your productivity dramatically.

@Fairydx
If you want to use:
custom/modules/Administration/views/view.winmax4authentication.php
you should active it in file:
custom/modules/Administration/action_view_map.php

You can look at as an example:
modules/Administration/action_view_map.php