Jump to content

Recommended Posts

Posted

I'm defining some options in the Select Option fieldtype as follows:

1=Kalundborg Red
1035=Education Teal
1036=Living Orange
1037=Good Life Blue
1038=Careers Cyan

However on saving the field it resets them to

1=Kalundborg Red
2=Education Teal
3=Living Orange
4=Good Life Blue
5=Careers Cyan

Any reason why I cannot specify the unique ID to use?

Posted

According to the docs there should be no issue with it:

"While we recommend letting the Options Fieldtype assign unique ID numbers for you, you may optionally assign your own. To do this, specify 123=title when adding a new option, where 123 is the ID number you wish to assign and title is the title text for your option."

https://processwire.com/api/modules/select-options-fieldtype/#adding-new-options

Also in the fieldtype_options table of database, option_id is int(10), so your numbers should work. Maybe a bug?

  • Like 1
Posted

I've just tried to assign custom integer values as @oma did, and I'm having the same issue.

5992ff7a4b0fd_ClipboardImage.jpg.c3182bc84fc33db1e7a7fedf21db36c5.jpg

Once I submit, PW tries to delete former options as well. This is probably the intended behavior.

5992ffb74b787_ClipboardImage(1).jpg.2f3cc8ba7711ea0e2b51391f85603c19.jpg

and once I confirm to delete those options, I get unique incremential ids for the new options

5993001f014b9_ClipboardImage(2).jpg.36f23ddb29d9e92ad35cf76750a458b4.jpg

Checking the database entries, it seems value field isn't filled at all, instead option id is returned

599301098892d_ClipboardImage(3).jpg.66d223de1368478c8288953a6444fccd.jpg

I'd say there's definitely a bug here.

  • Like 1
Posted
17 minutes ago, szabesz said:

According to the docs there should be no issue with it:

"While we recommend letting the Options Fieldtype assign unique ID numbers for you, you may optionally assign your own. To do this, specify 123=title when adding a new option, where 123 is the ID number you wish to assign and title is the title text for your option."

https://processwire.com/api/modules/select-options-fieldtype/#adding-new-options

Also in the fieldtype_options table of database, option_id is int(10), so your numbers should work. Maybe a bug?

Thanks for the help. Yeah... bizarre. I've always used 1, 2, 3, 4 etc but this time I needed higher values. I managed to edit the DB values directly and seemed to work fine so perhaps a bug as you say.

Posted
11 minutes ago, abdus said:

PW tries to delete former options as well.

I guess it is normal. IDs "cannot be edited". They get deleted first and afterwards new record is created.

  • Like 1
Posted

Could you do?

1=1|Kalundborg Red
2=1035|Education Teal
3=1036|Living Orange
4=1037|Good Life Blue
5=1038|Careers Cyan

Then you access it through $page->option->value 

  • Like 3
Posted
17 hours ago, szabesz said:

It is just a workaround, isn't it?

Yeah, I was meaning until the bug is fixed. 

  • Like 2
  • 9 months later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...