Jump to content

Developer Documentation

Tabs, headers and sidebars in IPS4 forms

For more complex forms, the \IPS\Helpers\Form helper provides a number of methods to help you organize and group your form fields:

  • Tabs (including determining which tab a field with an error exists in)
  • Headers (to group related fields under a title)
  • Sidebars (to enable you to add contextual content to a form)
  • Separators (to break a form into logical pieces)

Using them is simple:

$form->addTab('Tab1');
$form->addHeader('Header');
$form->add( new \IPS\Helpers\Form\YesNo( 'yes_no_field' ) );
$form->add( new \IPS\Helpers\Form\Text( 'text_field' ) );
$form->addHeader('Header');
$form->add( new \IPS\Helpers\Form\Text( 'another_text_field' ) );
$form->addTab('Tab2');
$form->add( new \IPS\Helpers\Form\Text( 'another_text_field' ) );

The form is built sequentially, so you should call addTab, addHeader etc. followed by the fields that should appear in that tab or under that header, before adding another tab, and so on.

 

Tabs

$form->addTab( string $lang [, string $icon=NULL [, string $blurbLang=NULL [, string $css=NULL ] ] ] )
  • $lang (string, required)
    The key of the language string to be used on this tab.
  • $icon (string, optional)
    If provided, will display an icon on the tab. Should be a FontAwesome icon classname, without the fa-. For example, cloud-download or envelope-o
  • $blurbLang (string, optional)
    If provided, will add some description text to the top of the tab contents, above the fields. Should be the key of the language string to use.
  • $css (string, optional)
    A string of space-separated CSS classnames to add to the tab content wrapper (note, not the tab itself). 

 

Headers

$form->addHeader( string $lang )
  • $lang (string, required)
    The key of the language string to use for this header

 

Separators

$form->addSeparator()

This method doesn't take any parameters.

 

Sidebar

Each tab can have its own separate sidebar (but a maximum one sidebar per tab, of course).

$form->addSidebar( string $html )
  • $html (string, required)
    HTML to show as the sidebar. You'd typically call a template here, for example:
    $form->addSidebar( \IPS\Theme::i()->getTemplate( 'group', 'app', 'location' )->myTemplate() );

     

 

 


  Report Document


×
×
  • Create New...