Jump to content

Universal Module: Pass Id_Value To Api, Check If Field Is Domain, Custom "return Messages", Description For An Input Field


André P.

Recommended Posts

Hi folks,

 

First of all: Thanks for the great idea of a universal module. Everything works as intended. :-)

 

1. Pass id_value to API

Is it possible to pass this value to the API? So far I work it around by using the Blesta API inside my API to get the value by client_id. That's an apiception I would like to avoid.

 

2. Check if field is domain

I created a field "domain" inside my module. I see I can have it checked for "isEmpty" and "isUrl", but I need a way to check if it is a domain. I can write a function to check it, but I don't know where to place the check (I am not good at objective coding stuff, sadly).

Another idea was to place some javascript at the bottom of the order template and check the field id against a regex.

 

3. Custom "return messages"

Can I return an error message e.g. "domain is in use" when calling the API? 

 

4. Add description for an input field

And the last one: Is it possible to add a description for an input field without modifying the PHP file? If not, it's fine, I would just go and modify it then. :-)

 

Cheers,

André

Link to comment
Share on other sites

1. Pass id_value to API

Is it possible to pass this value to the API? So far I work it around by using the Blesta API inside my API to get the value by client_id. That's an apiception I would like to avoid.

 

I assume you mean the `clients`.`id_value` field. This cannot be changed. It is set automatically based on your settings in Blesta with respect to other existing clients.

 

 

2. Check if field is domain

I created a field "domain" inside my module. I see I can have it checked for "isEmpty" and "isUrl", but I need a way to check if it is a domain. I can write a function to check it, but I don't know where to place the check (I am not good at objective coding stuff, sadly).

Another idea was to place some javascript at the bottom of the order template and check the field id against a regex.

 

There is no 'isDomain' validation rule, however, you can create your own using the 'matches' rule which validates according to your defined regular expression. You cannot write your own callback function to handle the validation from the UniversalModule (unless you actually update core code), so I don't think that would be the best route.

 

Here's an example:

{"service_label":{
    "valid":{
        "rule":["matches", "/^[0-9]{1}$/"],
        "message":"Label must be an integer"
    }
}}

3. Custom "return messages"

Can I return an error message e.g. "domain is in use" when calling the API? 

 

What do you mean? The API does not accept error messages, however, it makes error messages available to you if there are any. You can do anything with them.

 

 

4. Add description for an input field

And the last one: Is it possible to add a description for an input field without modifying the PHP file? If not, it's fine, I would just go and modify it then. :-)

 

Input field cannot set a description. How/where would such a description appear in the UI? Input fields could have tooltips associated with them, but the Universal Module does not currently support tooltips.

Link to comment
Share on other sites

  • 2 weeks later...

I assume you mean the `clients`.`id_value` field. This cannot be changed. It is set automatically based on your settings in Blesta with respect to other existing clients.

I don't want to change it, I want to pass it as value to my API. Like "https://something/api?action=add&id=clients_id_value.

The universal module does post the client_id to the API but not the clients.id_value. So far I use the Blesta PHP API to get the clients.id_value by client_id. I just wonder if there is a better way to do this.

 

There is no 'isDomain' validation rule, however, you can create your own using the 'matches' rule which validates according to your defined regular expression. You cannot write your own callback function to handle the validation from the UniversalModule (unless you actually update core code), so I don't think that would be the best route.

Thanks! I use a RegEx now + check for availability with JQuery in a custom order form template.

What do you mean? The API does not accept error messages, however, it makes error messages available to you if there are any. You can do anything with them.

I was talking about msgs like "Cannot add XY: Item exists". But that's not a problem at all... :)

 

Input field cannot set a description. How/where would such a description appear in the UI? Input fields could have tooltips associated with them, but the Universal Module does not currently support tooltips.

I thought about a label or something, but it is not really necessary either.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...