1

I have a current checkbox field which contains 8 options.

I want to change this field to a P&T checkbox field, to make use of the option_name : Option Label ability.

I've been told I can run an SQL find and replace from within the CP, but I've never done this before.

My field ID for the original field is id=6, and the new one is id=38

Can anyone help me with how I can transfer (or copy) the channel entires data from one field to another? Thanks!

Update

Thanks for the suggestions, will take a look at the fields now, and try it out.

Just so I'm sure i'm not doing anything unnecessarily, I am moving the data to a P&T field, as I need the ability to put the label and value. In order for the following code to work...

{walk_features_new}

    <li class="{option_name}"><strong>{option}</strong>
     <p>
      {if "{option_name}" == "option1"}Description for option 1{/if}
      {if "{option_name}" == "option2"}Description for option 2{/if}
      {if "{option_name}" == "option3"}Description for option 3{/if}
      {if "{option_name}" == "option4"}Description for option 4{/if}
      {if "{option_name}" == "option5"}Description for option 5{/if}
      {if "{option_name}" == "option6"}Description for option 6{/if}
      {if "{option_name}" == "option7"}Description for option 7{/if}
      {if "{option_name}" == "option8"}Description for option 8{/if}
    </p>
    </li>                               {/walk_features_new}

I am right in think that this would not be do-able with the standard checkbox field, as I could only output the {option} right?

Cheers!

1 Answer 1

1

You can run this SQL:

UPDATE exp_channel_data SET field_id_38=REPLACE(field_id_6, "|", "\n")

Where field with id 38 would be P&T checkboxes and field with id 6 would be checkboxes.

This SQL would work fine although it would be better if you can take a backup of database table exp_channel_data.

4
  • Thanks for that. Just tried it, but nothing has changed?
    – shorn
    Commented Feb 2, 2013 at 16:01
  • I am not sure if this sql didn't work. did you get any error message? Commented Feb 2, 2013 at 16:55
  • No error message, no. It actually says "Your query was successful" but non of the P&T checkboxes are now filled?
    – shorn
    Commented Feb 2, 2013 at 17:10
  • 1
    well, if you know the checkbox field type store the values separated with pipe ("|") while P&T checkbox stores the values separated with new line so in the query you can see first I am replacing "|" with "\n" of old checkbox field (id 6) and then that is being copied into into new P&T checkbox field (id 38). Commented Feb 2, 2013 at 17:20

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.