Jump to content

Dynamic configuration options for Textformatter module?


johannes
 Share

Recommended Posts

Hello Processwire community,

I am currently writing a configurable Textformatter module. For the configuration page I need a dynamic set of options, each consisting of two fields like so:

Option:

name1:value1

name2:value2

and so on…

At the moment I am using a JSON string in a text field but I was wondering if there is a better way to do this? Ideally I would be able to use a repeater, but I think that's not possible for a module configuration page, correct?

What's the best way to achieve this?

Link to comment
Share on other sites

Hi johannes and welcome!

If you only need to store key-value pairs, ProcessWire often uses a simple textarea where each line corresponds to a key/value pair.

In your code, you can get the keys/values by using PHP's explode function (newline as a delimiter).

Another possibility would be to dynamically create a new input field when clicking a button, but this requires some javascript to work.

I don't think that you can use an existing inputfield, but I might be wrong :)

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

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