Fieldmanager_Field::wrap_with_multi_tools PHP Method

wrap_with_multi_tools() public method

Wrap a chunk of HTML with "remove" and "move" buttons if applicable.
public wrap_with_multi_tools ( string $html, $classes = [] ) : string
$html string HTML to wrap.
return string wrapped HTML.
    public function wrap_with_multi_tools($html, $classes = array())
    {
        $classes[] = 'fmjs-removable';
        $out = sprintf('<div class="%s">', implode(' ', $classes));
        if ($this->sortable) {
            $out .= $this->get_sort_handle();
        }
        $out .= '<div class="fmjs-removable-element">';
        $out .= $html;
        $out .= '</div>';
        if ($this->limit == 0 || $this->limit > $this->minimum_count) {
            $out .= $this->get_remove_handle();
        }
        $out .= '</div>';
        return $out;
    }

Usage Example

 /**
  * Groups have their own drag and remove tools in the label.
  * @param string $html
  * @return string
  */
 public function wrap_with_multi_tools($html, $classes = array())
 {
     if (empty($this->label) || !$this->one_label_per_item) {
         return parent::wrap_with_multi_tools($html, $classes);
     }
     return $html;
 }