Custom input options for the custom TV

Hello everyone!

I’m developing my custom plugin (not extra that you need to install) to add some custom template variables into each modx site that I’m working with. I have followed this tutorial Custom Template Variables - Extending MODX | MODX Documentation - and so far everything is working fine, i have my first custom template called “customselect”, however, I’m wondering how could i add some extra “Input Options” in template variable settings (like Default Value):

I have seen that other default template variables have some different input options. Could somebody point to me to an example how to do it or give a bit more information about it?

Thanks guys!

Usually it’s best to look at other MODX extras, to see how to implement something:
For additional “Input Options” use the event OnTVInputPropertiesList.


For example the extra “Fred” adds a Yes/No combobox to the input options:

The event in the plugin:

Smarty template for the combobox:

1 Like

@halftrainedharry Thank you so much that works like a charm, by the way… how this value is stored in database?

The database table for the TVs (modx_site_tmplvars) has a column “input_properties”.

1 Like

Thanks for your response! That clarify a lot!
One more question what is responsible for saving this to this column? ext.js, modx object?

When you click the “Save” button in the manager to save the TV, the code makes an AJAX-request to the processor Element/Tv/Update (or Element/Tv/Create). The parameter “action” of the request defines the processor.

In the processor, the function “setInputProperties()” saves the values to the “input_properties” field:

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.