10

I have a Matrix that contains a P&T Dropdown field. I'm trying to control the markup generated by the Matrix, so I am trying to follow breaking up a matrix field for use in safe cracker form.
Though the example has a <select> (I'm assuming it represents a P&T Dropdown), it doesn't show how to loop through its list of options. Is there a way to do this?

3
  • Did the answer provided work for you? Commented Dec 30, 2012 at 1:33
  • No. I added some comments under Derek's response along with some additional information I found (albeit it being a year old). Commented Jan 1, 2013 at 16:42
  • I think your solution here is to write a custom plugin that retrieves those options and returns them as variables. Probably more work than is reasonable to expect from an answer here (IMHO). If you're comfortable writing plugins, I could certainly leave an answer that describes the steps. Commented Jan 2, 2013 at 13:18

2 Answers 2

6

Have you tried using the {options:field_name} syntax, as demonstrated in the Safecracker docs?

<select name="my_field_name[row_new_0][col_id_14]">
        {options:my_field_name}
                <option value="{option_value}">{option_name}</option>
        {/options:my_field_name}
</select>

I'm just not sure it will work with a third-party add-on like PT Select.

8
  • I don't this works because the P&T list doesn't store the item options in the same db field as the native option. Commented Dec 20, 2012 at 16:22
  • The {options:field_name} syntax supplied by Derek should work fine for looping through the options - I'm using the exact same syntax for P&T Dropdown fields in SafeCracker forms.
    – Stephen
    Commented Dec 28, 2012 at 20:33
  • Thank for the correction, I will have to test it again. The last time I tried it didn't work for me, I may have done something wrong inadvertently. Commented Dec 28, 2012 at 22:01
  • @Derek - is {options:my_field_name} supposed to be the Matrix field name? Shouldn't I be looping through the Matrix' cell instead? Say I have a Matrix field name foo which contains a PT Dropdown cell named bar. Is it supposed to be {options:foo} or {options:bar} or something else? Commented Dec 31, 2012 at 8:04
  • Just found this: getsatisfaction.com/pixelandtonic/topics/…. Brandon Kelly says there is no efficient way to do it. The post is over a year old, though. Commented Dec 31, 2012 at 8:23
1

I've not used this in a SafeCracker form, but in a Low Search form, I've used the Low Options plugin to output the options from a P&T Dropdown field, so it might be worth a try if you're still having trouble with this.

Your Answer

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

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