ajben Posted November 14, 2014 Share Posted November 14, 2014 hi, thanks for this nice extension. what's the best way to output the label instead of value? wohnung:=Wohnungeinfamilienhaus:=Einfamilienhaus i don't want to have "wohnung" rendered in this case... thanks! Link to comment Share on other sites More sharing options...
adrian Posted November 17, 2014 Share Posted November 17, 2014 Hi alekaj and welcome to the forums. I posted a bit of a hack to make this work: https://processwire.com/talk/topic/201-fieldtype-select-aka-drop-down/?p=45320 Hope that helps. 1 Link to comment Share on other sites More sharing options...
hellomoto Posted December 31, 2014 Share Posted December 31, 2014 I don't think there is a simple PW way to do this like $page->my_select->title. This is ugly, but works: foreach(explode("\n",$page->fields->my_select->select_options) as $option) { $valueLabel = explode(':=',$option); $value[$valueLabel[0]] = trim($valueLabel[1]); } echo $value[$page->my_select]; Damn thanks, I'm trying to do this right now, but wrap this up in a function. Does anyone know how that might be done? I tried this: function getValueLabel($fieldname) { foreach(explode("\n",$page->fields->{$fieldname}->select_options) as $option) { $valueLabel = explode(':=',$option); $value[$valueLabel[0]] = trim($valueLabel[1]); } return $value[$page->{$fieldname}]; } echo getValueLabel("currency"); but... yeah that doesn't work... Link to comment Share on other sites More sharing options...
adrian Posted January 1, 2015 Share Posted January 1, 2015 Damn thanks, I'm trying to do this right now, but wrap this up in a function. Does anyone know how that might be done? I tried this: function getValueLabel($fieldname) { foreach(explode("\n",$page->fields->{$fieldname}->select_options) as $option) { $valueLabel = explode(':=',$option); $value[$valueLabel[0]] = trim($valueLabel[1]); } return $value[$page->{$fieldname}]; } echo getValueLabel("currency"); but... yeah that doesn't work... Most likely the only issue is that PW variables like $page are not available inside functions due to PHP variable scope. If you replace $page with wire('page') is should work just fine. That said, this is why page fields are a better approach than this module for anything but the very basics (which it is great for!) when it comes to select type fields Link to comment Share on other sites More sharing options...
NorbertH Posted March 13, 2015 Share Posted March 13, 2015 Getting: Notice: Undefined variable: value in /var/www/web207/html/site/modules/FieldtypeSelect.module on line 65 whenever i store this field to an template from whithin the new "Actions" tab in the field settings. ProcessWire 2.5.20 dev Edit: It happened because i wrote 1:=option1; 2:=option2; .... instead of separating it by Return But myabe it would be nice to have a valid error message if you have invalid options. Link to comment Share on other sites More sharing options...
apeisa Posted March 13, 2015 Share Posted March 13, 2015 There is now "options" fieldtype in core. You can use it instead. 2 Link to comment Share on other sites More sharing options...
adrian Posted March 13, 2015 Share Posted March 13, 2015 What apeisa said, but that error makes me think you've got something incorrect in your Details > Select Options textarea because $value is not being set. The only way I can make that happen is to have more than one ":=" on a row. Of course the module should have a better check on this, but I still think you might have something incorrectly configured. EDIT - I see you found your error 1 Link to comment Share on other sites More sharing options...
NorbertH Posted March 13, 2015 Share Posted March 13, 2015 As i already said , on first try i copied the "1:=Poor, 2:=Excellent" line from the description on first try. So it was my fault not reading the documentation properly, but still there should be a check. @apeisa Thx for the info, i missed that field completely Link to comment Share on other sites More sharing options...
Vayu Robins Posted June 26, 2015 Share Posted June 26, 2015 Hi, is the Fieldtype: Select (AKA Drop Down) moduel (version 1.2.0) compatible with ProcessWire 2.6.1? It says it's compatible with ProcessWire 2.4. Link to comment Share on other sites More sharing options...
Pete Posted June 26, 2015 Share Posted June 26, 2015 You should use Fieldtypeoptions now which is built into the 2.6 branch - it is a core module that does the same and more 2 Link to comment Share on other sites More sharing options...
hollyvalero Posted May 7 Share Posted May 7 I use the Fieldtype: Select (AKA Drop Down) a lot. And I'd be happy to switch to the Fieldtypeoptions, but I need something that allows me to create a variable, and show a human name to the user ... Something like this: left:=left right:=right The FieldtypeOptions creates this: 1:left 2:right I use them for a variety of things like choosing image effects on photos... uk-background-blend-color-dodge:=Color Dodge uk-background-blend-color-burn:=Color Burn uk-background-blend-hard-light:=Hard Light where I can add to the code: {$item->imagefx} on an image. What is the workaround for this? Link to comment Share on other sites More sharing options...
bernhard Posted May 7 Share Posted May 7 For options you can define the id, a value and a title (aka label): 123=value|title So you could create these options: 1=left|Left aligned image 2=right|Right aligned image In your code you can then access either one of those three. See https://processwire.com/docs/fields/select-options-fieldtype/ Would that match your needs? 2 Link to comment Share on other sites More sharing options...
hollyvalero Posted May 7 Share Posted May 7 (edited) 55 minutes ago, bernhard said: 1=left|Left aligned image 2=right|Right aligned image Okay, never underestimate the power of anxiety... this seems to work: {$page->fieldName->value} Edited May 7 by hollyvalero I think I got it... Link to comment Share on other sites More sharing options...
cb2004 Posted May 7 Share Posted May 7 Might also be worth mentioning, it looks like you are trying to set the crop point of an image. Do you know about focus points on images with newer versions of ProcessWire? There would be no need for a dropdown then. 1 Link to comment Share on other sites More sharing options...
hollyvalero Posted May 7 Share Posted May 7 1 minute ago, cb2004 said: Do you know about focus points on images with newer versions of ProcessWire? * Oh, yeah... I'm using these for things like moving a photo from the left side of a block to a right side, adding padding of various amounts, etc. 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