Fieldmanager_Field::form_element PHP Method

form_element() public method

public form_element ( $value ) : string
return string HTML for the element. Generate HTML for the form element itself. Generally should be just one tag, no wrappers.
    public function form_element($value)
    {
        if (!$this->template) {
            $tpl_slug = strtolower(str_replace('Fieldmanager_', '', get_class($this)));
            $this->template = fieldmanager_get_template($tpl_slug);
        }
        ob_start();
        include $this->template;
        return ob_get_clean();
    }

Usage Example

 public function form_element($value = null)
 {
     list($context, $subcontext) = fm_get_context();
     $this->autocomplete_attributes['data-context'] = $context;
     $this->autocomplete_attributes['data-subcontext'] = $subcontext;
     $this->autocomplete_attributes['data-action'] = $this->get_ajax_action($this->name);
     $this->autocomplete_attributes['data-nonce'] = wp_create_nonce('fm_search_nonce');
     $this->autocomplete_attributes['data-args'] = json_encode($this->ajax_args);
     return parent::form_element($value);
 }