Jump to content

Outputting the value of the selected radio button (page field)


Christophe
 Share

Recommended Posts

Hi,

I've tried several things (before posting), they don't seem to work.

It's the first time, if I remember well, that I use "Radios" or "Checkboxes" page fields in order to display the values on the front-end.
 

I've just managed to make the checkboxes' ones work with PHP's implode function (with delimiters).

But I can't manage to make the radios' ones work.
Not sure to remember well as I first tried with "Radios" a few hours ago (and have forgotten to eat...) , but I think that I tried with things like:

$page->nameofthefield->title

and

$page->nameofthefield->name

seen in posts.

I've tried with a foreach, but (logically?) it adds another radio button's value each time I change the selected one and save the page.

I need some experts' help.

Thank you so much in advance!

Edit: I'm using ProcessWire 2.8 (for the first time - upgraded recently).

Link to comment
Share on other sites

3 hours ago, Christophe said:

It's the first time, if I remember well, that I use "Radios" or "Checkboxes" page fields in order to display the values on the front-end.

The inputfield you choose for your Page field has no impact on how you access the field value using the API. So it's just like any other Page field. The important setting is "Dereference in API as" and this determines whether your field value is a PageArray or a Page object.

  • Like 2
Link to comment
Share on other sites

Hello @Robin S,

I had seen this but I guess I was "afraid" that changing the setting would mess things up, but it's only for the API.

I wanted to still be able to change the selected radio button if needed. Perhaps I thought that if I changed this setting I would lose all the other choices.
I don't know why, as even then, as the pages would still be there , I could easily have had them all again by reverting back to the previous setting.

Thank you :)!

Have a nice weekend!

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...