Jump to content

Custom fields for ConfigOptions in Module API


Recommended Posts

When developing a custom server module, the forms that are generated do not have a way to supply a different label/value for the options in a dropdown or a radio form. You can only supply a comma-separated list of values, e.g.

 

"subscription" => array (

"FriendlyName" => "Subscription Term",

"Type" => "dropdown",

"Options" => "1,12,24",

),

 

But that's no good if you want the user to see "Month", "Year", etc. This becomes really important if you need to pass unique IDs to your server API, but you need to display human readable text to your user.

 

Does WHMcs have this ability? Seems like the form generation bit here is too simplistic... couldn't there be something more complex than simple comma-separated values? E.g. a JSON array or a semi-colon or something?

Link to comment
Share on other sites

  • 4 weeks later...

No that doesn't work: the module settings stuff accepts only a comma-separated list of values. This should be in the docs somewhere... From the WHMcs tech support:

 

[Key/Value pairs] is not something that is possible on the "Module Settings" tab of the product, You could have just the ID, just the name, or the ID|Name and then explode the | in the module coding.

 

Generally, the Module Settings does not matter as only the person configuring the product would see this. It is more about the client side and what the client would see. With this, you can use configurable options and have a System Value and a Friendly Value. The system value is passed to the module whilst the friendly value is displayed to the client in the clientarea. This is done using |. This will work on the Configurable Options name and the values. For example diskspace|Disk Space would should Disk Space to the client, but diskspace in the module code. The same applies to the values of the configurable options (and custom fields). You can have an option with the value 123|New York, the client would see New York and the module would receive 123.

Edited by fireproofsocks
tech support answered the question.
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated