Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.1k views
in Plugins by
In a plugin, I want to add some info above the admin form. I can add a "note" to each of the form fields, but I don't see a way to add any custom stuff.

Is the form structure documented? I know there are the fields ok, style, fields, hidden and buttons, is there anything else?
Q2A version: 1.5.2
by

Hey Scott,

Can you clarify what you mean with admin form? Where can this be found?

by
edited by
It's the form that is displayed in the Admin section for a plugin. There is a function admin_form() that you can use to display options etc for a plugin, and you need to return an array specifying the form, e.g.

return array(
  'ok' => $saved_msg,
  'fields' => array(
    // fields here
  ),
  'buttons' => array(
    // buttons here
  ),
);

1 Answer

+1 vote
by
selected by
 
Best answer

I'm afraid it's not documented.

You can have custom fields in a form which display arbitrary HTML. Take a look at function form_field(...) in qa-theme-base.php for all the element types.

You can also add a 'title' key to a form, and the value will be output above the form within <H2> ... </H2> tags. In the case of a plugin's admin form, this will replace the title that is shown by default, i.e. the plugin's name.

by
Thanks, I went for the below in the interim (a blank form field with a note), sounds like this is probably the best way.

$fields = array(
    array(
        'style' => 'tall',
        'type' => 'static',
        'note' => 'The text',
    ),
);
...