1

I have a safecracker form that allows users to post location details. At the moment, I use a combination of a standard for them to choose the country, and the reegion select fieldtype to select the UK county. Based on there selections, I manually add the category based on these selections.

I am looking for an easier way for the user to add the details in teh safecracker form, and what I would ideally like, is a way for them to choose just the county, from a grouped select.

Something like:

This one

Which would be,

England

  • County
  • County
  • etc

Scotland

  • County
  • County
  • Etc

and so one.

This means they only have to make one select within the form, and it would be easy to validate. Is there a way to produce this type of dropdown from an EE field, that would also be compatible with safecracker and its inline validation?

I'm thinking I could also make this a grouped category dropdown maybe? Although I do like to have the country/county replicated in normal fields as it's easier to pull into templates.

Any help appreciated!

Thanks!

1 Answer 1

2

Absolutely - you can use the P&T Dropdown fieldtype (part of the free P&T Field Pack). You'd setup your options in the fieldtype settings like so to create grouped options:

 : Select your county
England
    County 1
    County 2
    County 3
Scotland
    County 1
    County 2
    County 3
4
  • Yes, I've just seen this one! But I think I might end up getting issues with Safecracker, similar to this one: expressionengine.stackexchange.com/questions/5801/…
    – shorn
    Feb 4, 2013 at 15:28
  • Right, I have this is (P&T drop down) in and displaying nicely within my Safecracker form, it also validates fine, and keeps the selection remembered. Now I'm using the {field:short_name}to display the select, but ideally I would rather use an options loop, as it will allow me greater control over styling. Any ideas on the best way to do this, bearing in mind the dropdown has option groups?
    – shorn
    Feb 4, 2013 at 20:33
  • No simple solution that I'm aware of. I'd suggest wrapping the {field:short_name} tag in a classed div, then targetting the interior elements with CSS. (This won't allow you to control markup of course.) Feb 4, 2013 at 20:47
  • Yep, I think that's what I'm going to have to do. The P&T field pack (together with Safecracker) have been giving me headaches all day!
    – shorn
    Feb 4, 2013 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.