Jump to content

Developer Documentation

Forms

  1. Overview of the IPS4 Form Helpers

    Purpose of the Form Helper Much of the UI in IPS4 revolves around forms, whether it's the numerous settings screens in the AdminCP, replying to content on the front end, configuring your profile, and so on. The IPS Community Suite has a powerful Form Helper class that simplifies implementing forms in your applications and plugins. It provides features such as automatic validation and built-in security, and (in the case of more complex field types such as matrices and node/tree selector
  2. Displaying a form

    Outputting the form Casting the $form object to a string returns the HTML to display the form. You don't usually need to cast the form explicitly, simply adding it to the output buffer (e.g. \IPS\Output::i()->output) will be fine. e.g. \IPS\Output::i()->output .= $form;   Adding custom CSS to a form By default, the form is "horizontal". To use "vertical", or to apply any other classes to the form, you can do: $form->class = 'ipsForm_vertical'; The class prop
  3. 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\H
  4. Using field toggle functionality in forms

    What are toggles? Frequently in form design you'll want to show or hide groups of fields depending on the values of other fields. For example, assume you have a Yes/No field that enables some feature, and some other fields that customize how the feature works. When the user checks 'No' to disable the feature, you can hide the other fields using toggles (and show them automatically when 'Yes' is checked). By doing so, you simplify your form design, and make it easier for users to understand
  5. Handling File Uploads

    To allow file uploads in your code, you use the \IPS\Helpers\Form\Upload class within the Form Helper. The administrator has the ability to control how to store different types of file - due to this, using an Upload field is slightly more complicated than most other form types.   The FileStorage extension You are required to create a FileStorage extension within your application which is mostly used to provide callbacks to locate files uploaded by your field. To get star
  6. Using the rich-text (WYSIWYG) editor

    To use the WYSIWG editor in your code, you use the \IPS\Helpers\Form\Editor class within the Form Helper. Editors automatically have the ability to support attachments, and the administrator can customize the editor to make certain features available in some areas and not others. Because of this, using an Editor is slightly more complicated than most other form types.   Creating an EditorLocations extension You are required to create an EditorLocations extension within your a
  7. Using translatable field types

    Translatable text fields can be used to allow the user to provide a different value for all of the different languages they have on their community. If only one language is installed, then a single text field is shown instead. Translatable fields are commonly used for when an administrator has to provide the name for something which may need to be different depending on the language. Tip Translatable fields are designed to be used inside the AdminCP only. They are no
×
×
  • Create New...