Buy Now
Sign in

radiobox values

ernst@volny.cz , November 15 2020, 22:16
E
ernst@volny.cz 164
November 15 2020, 22:16 #394852
how do I get to the radiobox values after submitting the form
I need to get to the color names.
1=red
2=blue
3= green
I know this description is stored next to the field in $this in ["options"], but I don't know the path to it. Or there is another way to find this value?
GreyHead 65
November 16 2020, 13:06 #394862
Hi ernst,
The simplest way is to use the names as values e.g. red=red
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
E
ernst@volny.cz 164
November 16 2020, 13:51 #394864
but i still need to work with rate "1" and "red"
i need both for further processing in the form
GreyHead 65
November 16 2020, 20:35 #394870
Hi Ernst,
You can use a few lines of custom code on submit to look up the 'extra' info you need.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
E
ernst@volny.cz 164
November 16 2020, 21:45 #394872
I'm sorry, but I don't understand what you mean.
I write my own php codes and own javascripts in the form, but I don't know how to use them to get to the required information
healyhatman 9
November 17 2020, 00:05 #394873
In PHP

$values = [1 => 'red', 2 => 'blue'];

return $values[$this->data('radio_group_input_name')] ?? null;
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
E
ernst@volny.cz 164
November 17 2020, 08:33 #394887
I understand clearly, but I wanted to avoid entering values in two places
I did it by giving
1 <span>red</span>
and I control the display and calculations by working with strings
in this example it's not so understandable, but imagine I have an event and its price:
bar <span> 5 eur </span>
action 1 <span> 7 eur </span>
action 4 <span> 6 eur </span>
and I need to know the price and the action.
This is enough to write it once, but when writing
5=bar
7=action 1
6=action 4
I would have to change those values in the radiobox and in php
it would be user unfriendly