entschleunigung Posted June 12, 2020 Share Posted June 12, 2020 Hello, everyone, i have created a radio field as follows 1=Mr|Mr 2=Ms|Ms the following is output in the source code: <input type="radio" name="name" id="id" class="class" value="1"> but I need: <input type="radio" name="name" id="id" class="class" value="mr"> how do I get the value to be output instead of the id? thx Link to comment Share on other sites More sharing options...
louisstephens Posted June 12, 2020 Share Posted June 12, 2020 If you are using the Select Options fieldtype, I believe all you have to do is: <?php echo $page->your_field->title; ?> // will get "Mr/Ms" 1 Link to comment Share on other sites More sharing options...
entschleunigung Posted June 12, 2020 Author Share Posted June 12, 2020 hi @louisstephens, thank you, of course it works that way too, but i use the option field in the user-template in connection with the loginregister module and i wanted to avoid hooks or something like that. Link to comment Share on other sites More sharing options...
MoritzLost Posted June 12, 2020 Share Posted June 12, 2020 @entschleunigung Why do you want to change the format though? SelectOptions are saved by ID, so that you can change the values and labels of individual options without changing selected options in existing pages. If you change the output format, you'll have to change the format they are saved in as well, that will require hooks also. Why not just let the module save the options as IDs and output the values / titles in your templates as you need them? Users don't see the value of the options in a radio input, after all ... just the labels. Or are the labels not rendering for you? Link to comment Share on other sites More sharing options...
entschleunigung Posted June 12, 2020 Author Share Posted June 12, 2020 hi @MoritzLost, you are right of course, normally i don't have to change the format, but in this case i send the information to an external source (subscribe newsletter) that can only handle values like "mr" or "ms". (to complete it: via the LoginRegister module a user is registered and at the same time the newsletter registration is done) sorry if the information comes in bits and pieces, but i thought if i write the following, as described in the document 1=mr|Mr that in this case ProcessWire will take the value instead of the ID when the input radio is rendered. it seems i was on the wrong track ? greetings & servus Link to comment Share on other sites More sharing options...
MoritzLost Posted June 12, 2020 Share Posted June 12, 2020 Well, if you look through the database, you can see that SelectOption fields are always saved by ID (i.e. the value that goes into the database for this field is the selected option's ID). The mapping of IDs to values and labels is done through the central field definition. So changing that would be a lot of work. Can't you change the API call (or whatever) to the external service to use the value instead of the ID? 1 Link to comment Share on other sites More sharing options...
entschleunigung Posted June 12, 2020 Author Share Posted June 12, 2020 thanks first. as soon as i get back to the office, i'm gonna go test this out. as louis suggested, maybe it could work out that way: "salutation" => $user->my_field->title; currently, it's like this "salutation" => $user->my_field; and only the ID goes out there. vor lauter bäumen und so ... thx 1 Link to comment Share on other sites More sharing options...
entschleunigung Posted June 15, 2020 Author Share Posted June 15, 2020 Needless to say, that's exactly how it works. Thanks again, you two. Greetings 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now