Support

Account

Home Forums Backend Issues (wp-admin) ACF Field using WYSIWYG Editor Reply To: ACF Field using WYSIWYG Editor

  • If you really want to allow pasting all of the items at once, or this was a requirement by the client, using what is available I would choose a textarea field and I would include instructions about putting each ingredient on a new line. Very similar to how the choice settings for radio, checkbox and select fields work in ACF. I would set the formatting of the text field to “No Formatting”. I would then parse the value of the field either by getting the value and parsing it or I’d build an acf/format value filter that would do the formatting so I don’t have to re-code the parsing or call a function.

    
    add_filter ('acf/format_value/name=my_field_name', 'format_my_field_name', 20, 3);
    function format_my_field_name($value, $post_id, $field) {
      if (!$value) {
        return $value;
      }
      $array = acf_decode_choices($value);
      if (!is_array($array) || empty($array)) {
        return $value;
      }
      ob_start();
      ?>
        <ul>
          <?php 
            foreach ($array as $line) {
              ?><li><?php echo $line; ?></li><?php 
            }
          ?>
        </ul>
      <?php 
      $value = ob_get_clean();
      return $value;
    }