State Input Helper
Version 0.1.1 added 2 years ago by tlainevool
HOW TO INSTALL: To install this package, copy the following code and paste it into your Pods >> Package Manager under the Import tab and follow instructions there.
0.1.1 Notes
Initial Version
About this Package
This input helper creates a drop-down based on all the values from the states table, so that users can only select valid states. The column that uses this input helper should be a txt type.
To use this go the the Pod where you want to use it, create a column named "state", make it single line text type , and select the "state-input-helper" for it.
Some notes on the code, because it was a little more complicated than I expected.
- You can't do a normal findRecords on the state Pod. The state information isn't in the wp_pods table, so I had to use custom sql to get the states.
- To simplify things I put the "list template" code directly in the showTemplate call. This allows all the code to be in a single chunk instead of having a helper and a separate template.
- To be able to use the current value of the column in the template I used the global $pods->data. This seems kind of hackish, but I couldn't think of another way to do it.
To use this go the the Pod where you want to use it, create a column named "state", make it single line text type , and select the "state-input-helper" for it.
Some notes on the code, because it was a little more complicated than I expected.
- You can't do a normal findRecords on the state Pod. The state information isn't in the wp_pods table, so I had to use custom sql to get the states.
- To simplify things I put the "list template" code directly in the showTemplate call. This allows all the code to be in a single chunk instead of having a helper and a separate template.
- To be able to use the current value of the column in the template I used the global $pods->data. This seems kind of hackish, but I couldn't think of another way to do it.
