Pete Posted July 16, 2012 Posted July 16, 2012 I did have need for a few things like this and it did take while to wrap my head around, but as long as the benefits are explained it's not a problem. I would put it into context and explain that if you added age ranges (assuming you were collecting user stats during sugnuo or doing a quiz or something like that) then you can use this with selectors to pull simple stats. The benefits aren't always immediately obvious as you might not have need it using such a simple field with selectors at the time you create the field, but the flexibility it offers if you do need to do something like that is amazing.
Oliver Posted October 17, 2012 Posted October 17, 2012 Hey Hani, I tried your select field module, as I need just a drop down with three options and I don't want to setup a Page field with three pages for a case like this. Setup worked out fine. But the value entered on page edit isn't saved to the fields db table. Any idea why? 1
Nico Knoll Posted December 21, 2012 Posted December 21, 2012 The problem is line 51. It looks like: $inputfield->addOption((string) $option); And has to look like: $inputfield->addOption((string) trim($option));
buothz Posted January 17, 2013 Posted January 17, 2013 (edited) I've this output <li class='Inputfield InputfieldSelect Inputfield_auto_marca ui-widget InputfieldStateRequired' id='wrap_Inputfield_auto_marca'> <label class='ui-widget-header' for='Inputfield_auto_marca'>Marca</label> <div class='ui-widget-content'> <p class='description'>Marca</p> <select id="Inputfield_auto_marca" class="required" name="auto_marca"> <option selected='selected' value=''></option> <option value='fiat'></option> <option value='bmw'></option> </select> </div> </li> why <option value='fiat'></option> and not <option value='fiat'>fiat</option>... I've not change files of your module... where's the problem? thanks EDIT -> corrected file InputfieldSelect.module your version $out .= "\n\t<option$selected $attrs value='" . htmlspecialchars($value, ENT_QUOTES, "UTF-8") . "'>" . $this->entityEncode($label) . "</option>"; my version $out .= "\n\t<option$selected $attrs value='" . htmlspecialchars($value, ENT_QUOTES, "UTF-8") . "'>" . htmlspecialchars($value, ENT_QUOTES, "UTF-8") . "</option>"; why this error? Can be a server problem with "$this->entityEncode($label)"? Edited January 17, 2013 by buothz
Macrura Posted August 12, 2013 Posted August 12, 2013 Hi Hani - thanks for this module, comes in handy once in a while.. One problem: seems that if you don't use a pair, the $label is null and then you have no labels in the dropdown. i changed line 55 to this: $label = $value; and it works, not sure why or how setting the label to null works, iguess the select field is supposed to handle that, but it isn't doing it also i noticed that the database was showing \r\n and not just \n so i changed line 50 to this; $options = explode("\r\n",$field->select_options);
Soma Posted August 12, 2013 Posted August 12, 2013 I noticed this too, that it doesn't work when no key is set only label. Not sure about the \r\n, I think that's system dependence. I also noticed that if you enter 0 as a key (0:=option) it will not work with querying with selectors, as the data field is a text field and not a integer. YOu have to start with 1:=option to make it work.
Paul Posted October 1, 2013 Posted October 1, 2013 Thanks for this great module! I have one problem: How can I display the label of a specific option in the frontend? If I use $page->my_select I just get the option value, but not the label.
adrian Posted October 1, 2013 Posted October 1, 2013 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]; 2
Sinmok Posted November 20, 2013 Posted November 20, 2013 I've just noticed something about this module. If you set the input required field to "Yes" and then try to save a page without selecting an option, it comes back with an error saying it's required..but all the values on the rest of the page still save. Is this a bug with this module or across the board?
Soma Posted November 20, 2013 Posted November 20, 2013 It will save fields but you can't publish page. 1
ryan Posted November 23, 2013 Posted November 23, 2013 If a page is unpublished, PW won't let you publish it until you can save it error free (meeting required fields, etc.). If the page is already published, then ProcessWire is not going to prevent you from saving it, but will warn you that the field is required.
bwakad Posted March 22, 2014 Posted March 22, 2014 After reading this topic I have some questions, I am fairly new to processwire and still trying to bend my head around it: I need a select field, large quantity of options, able to change it's values in admin, reflect the changed in front output after a change. In this topic it is recommended to use page field. Some say make pages - but that would mean I have to create a page for every option - and I need at least 30. Or are there other things available? For example: brancheA (option/value) - and clicking a link to BrancheA - would display a (search) page with list of items under that branche etc.
teppo Posted March 22, 2014 Posted March 22, 2014 Pages are the preferred way to do this and 30 pages is absolutely not a problem. You'll run into usability issues with select field itself much sooner than any kind of problem related to number of pages behind the scenes.. 1
cstevensjr Posted March 22, 2014 Posted March 22, 2014 Pages are the easiest way to work with ProcessWire. You can even use Ryan's Import Pages from CSV module to help you create them.
Joss Posted March 22, 2014 Posted March 22, 2014 @bwakad If you just think of a page with a title as just the title (and forget that we are calling it a page) then it does not seem so over the top. This may help: http://wiki.processwire.com/index.php/Page_Field 1
bwakad Posted March 22, 2014 Posted March 22, 2014 Yes, I was also reading a tutorial joss wrote earlier, they are almost the same. But then it confused me to: Do I need to add a file in the templates folder on the server, OR add a file in the admin part under templates? Then it says 'blank template' but I really could not tell what is meant by that... As for the video page field: I followed those steps in the video, but how to display in the .php template file? I looked into the cheat sheet but did not find which is outputting what?
Joss Posted March 22, 2014 Posted March 22, 2014 When it comes to create a select of any sort, you only need a template file if you will need to display those pages as actual pages, if you see what I mean. What I tend to do is create a template that will be used as a parent (no file, just a blank template), and then create a template that you will use for the actual options. A lot of the time you can just have the title field, but if you need a value that is different from the title or you need more fields for other reasons, just add them. With the parent template, set the family so that it can have children and define the template that will be used for those children. Create a page with the parent template that you want as the parent for your select. Then create some children - it will automatically choose the template you set as the child template. Since the parent template does not have a template file, it will not show up on any menu or similar searches. If you want that to be a bit more obvious on your page tree, set it as hidden as well. Now you can create a page field and that will be your selects. You can even set the page field so that it can create more options - very useful for things like tags. This sounds long winded, but actually, it takes just a few minutes
bwakad Posted March 22, 2014 Posted March 22, 2014 I understand what you are trying to tell me, but still it is not very clear: 1. I made a new template from setup>templates>addnew 2. I added those two fields as suggested in the wiki - the normal title field and a text field called select_value 3. I created a top page - Selects and here is where I get confused: in this page under settings I see template* name-of-template (from step 1)... Now, what/where is the blank template? I really feel stupid now. lol
Joss Posted March 22, 2014 Posted March 22, 2014 The parent page also needs its own template - you can create one and call it anything you like, I just called mine blank template to make it clear it didn't have any additional fields. It needs a template so you can, for instance, set it to use a specific template for any children. So, once you create a template for the parent, create a page with that template - you will only need the one page, obviously. Then go an add some children to this parent page using the template you created for your selects. When you create your page field, you will then select the parent page as, umm, the parent page! (Clever, huh?)
Nico Knoll Posted June 12, 2014 Posted June 12, 2014 I created a pull request at GitHub. Changed only like 5 lines. But should be much nicer now 1
OrganizedFellow Posted August 10, 2014 Posted August 10, 2014 I was in need of something like this tonight and I'm glad i found it. Imagine my 'sadface.gif' when it did not work as expected. Maybe it's just that I don't understand it? So on the Details page of my select option. I put: apple:=apple banana:=banana cherry:=cherry And it works as expected. But if I do this: apple banana cherry The dropdown is blank in my Page. First I downloaded via the ModulesManager. Then I cloned frmo github. They are both the same version.
Nico Knoll Posted August 10, 2014 Posted August 10, 2014 Yeah, use my fork and it will work:. Hani still didn't merged it... https://github.com/NicoKnoll/Processwire_FieldType_Select_Drop_Down/tree/patch-1 2
OrganizedFellow Posted August 10, 2014 Posted August 10, 2014 Yeah, use my fork and it will work:. Hani still didn't merged it... https://github.com/NicoKnoll/Processwire_FieldType_Select_Drop_Down/tree/patch-1 Thank you. Worked like a charm 1
adrian Posted August 13, 2014 Posted August 13, 2014 I see that Hani has merged Nico's fixes so should be all good: https://github.com/Hani79/Processwire_FieldType_Select_Drop_Down/commit/d2f3a15da5690b535b908dc7fe4644201ebd6eed 1
MuchDev Posted August 14, 2014 Posted August 14, 2014 So Im not quite sure what I'm doing wrong here but Im having a hard time getting a value to show up. I have 4 options: 1:=1 block 2:=2 blocks 3:=3 blocks 4:=4 blocks now if I save the value in the page to say option 2 or 2 blocks when I choose $page->itemGridSizer I recieve no output. Is that the correct syntax? edit: I jsut treid to set it to 1 2 3 4 and still no dice, is this a bug or just something I'm doing wrong? **final edit** After some serious tinkering I coaxed my code into working. It turned out that for some reason the included code did not have access to the field, and I just needed to pass my function the variable. php noob mistake sorry for the junk On a side note this plugin is awesome!! I needed something that would allow me to let the client choose one of four bootstrap layouts to use with my masonry javascript and it really blew em away! I love processwire, and I thank you for making such a useful tool.
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