Jump to content
timnboys

Input->SetError no longer works on addservice() method

Recommended Posts

8 hours ago, timnboys said:

Hello could anyone including @Paul @Tyson @Cody @Jono help me with stopping the addservice() function in a module on error.


$this->Input->setErrors(array('api' => array('internal' => "ErrorMessage", true)));
return;

^ that seems to no longer stop the service from being added as it should.

the same code was working before ?

Share this post


Link to post
Share on other sites
8 minutes ago, Blesta Addons said:

the same code was working before ?

I don't know to be honest, after checking the functionality of the module everything was screwed up because it returned to modules/installed after trying to delete a module row, so maybe it was related to that, who knows.

Share this post


Link to post
Share on other sites
1 minute ago, timnboys said:

I don't know to be honest, after checking the functionality of the module everything was screwed up because it returned to modules/installed after trying to delete a module row, so maybe it was related to that, who knows.

try

 

            $this->Input->setErrors(
                ['module_row' => ['error' => "error here"]]
            );
            return;

 

Share this post


Link to post
Share on other sites
40 minutes ago, Tyson said:

I don't encounter this issue myself. YourModule::addService can set errors to the Input component in order to prevent service creation. I'd need more context to determine the issue you're experiencing.

I fixed that somewhat already now I am running into another issue on the backend api, it seems this is erroring on trying to create a invoice from the service:

Undefined index: inv_type                on line <strong>2853</strong>
                in <strong>/var/www/html/app/models/invoices.php</strong>

Share this post


Link to post
Share on other sites

It sounds like your company does not have all of its settings defined for some reason. You may want to update the company settings under Settings > Billing/Payment > Invoice Customization and re-save the settings. The one you're missing based on that error is the "Invoice Type".

Share this post


Link to post
Share on other sites
1 hour ago, Tyson said:

It sounds like your company does not have all of its settings defined for some reason. You may want to update the company settings under Settings > Billing/Payment > Invoice Customization and re-save the settings. The one you're missing based on that error is the "Invoice Type".

well I found that setting company_settings not $client_settings as app/models/invoices.php is referring to hence the error.

Share this post


Link to post
Share on other sites

Hello, maybe it's not related to your problem but in my case setting an error in the "addService" module method raise an error on line 5742 of /app/controllers/admin_clients.php.

On line 5707: $service_id = $this->Services->add($item, $package_ids, $notify); the method is returning null since an Error has been set on the Input module, however on line 5713 "$service_id" is appended to the array "$service_ids": $service_ids[] = $service_id;

So on line 5716 the array $service_ids is not empty, raising then the error with the updateServicesRenewalForProration function.

I solved the problem editing the admin_clients.php on line 5713, appending the $service_id to $service_ids only if not empty:

if (!empty($service_id)) {
    $service_ids[] = $service_id;
}

 

I'm using Blesta 4.2.2, PHP 7.0.27

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×