Jump to content

Recommended Posts

Posted

Hey there,

I have a page field in the form of radio buttons, where the user can select the importance of the article: Very important, important, normal. 

I would like to make the default value "normal", but can't think of any way of doing it.

Any help?

Thanks

Posted

Hi Lenoir, I think this has come up a few times and I don't think there is a way of setting a default in the admin side.

What you can do however is use if/else statements in the template:

if ($page->field == "very_important") {
  // do something
} elseif ($page->field == "important") {
 // do something different
} else {
 // user has either selected normal or left it blank so use normal
}
 
  • Like 1
Posted

Thanks onjegolders,

Did this already. It's mainly an issue in the admin page: I would really like one of the items of the radios to be selected.

Posted

Yeah I don't think this exists at the moment but I can see why you'd want it. I think it's strange seeing radios without a default setting. Maybe it's something Ryan can add to the wishlist?

Posted

It's not always good practice to have default value set for various reasons and there's some discussion about it in the forums.

You have "normal" .. is it really needed to have that as a selectable state? All default entries are "normal" and should be handled in template code.

Just create option with dropdown (as radios have no blank) and have "important" and "very important" as states.

  • Like 2
Posted

Soma: that's an interesting thought.

I don't know what the discussions are in the forum, but i can only see one small issue with this solution: it can be confusing to select a blank item of a dropdown if the user wants to go back to the "normal" state.

Still I'll give it a go, since it'd be a better solution than a radio without default value.

Thanks.

Posted
Hey, is this new?
Cool: mods.pw/3y

All modules now have their own short URL off mods.pw. The letter combo used is the base 62 value of the module's ProcessWire page ID minus 1000. For example "3y" translates to 1246. Just a way to keep them as short as possible. 

  • Like 2

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
×
×
  • Create New...