Jet\Form_Renderer
General abstract class of renderers of all form elements - i.e. the base class from which all other renderer classes inherit.
Overview of methods
Method | Meaning of |
---|---|
public getViewDir( ) : string |
Returns the path to the view root directory of the form element scripts. There are several important factors here:
|
public setViewDir( string $views_dir ) : void |
Sets the path to the root directory of the view scripts of the form elements. See the getViewDir method. This method also works cascading. So, for example, you can set the whole form to a different root path than the default one - set by the system configuration. This is useful, for example, when you are creating a form with a completely unique design. The path set in this way is then relevant for all elements of the form. You can also set a custom path for individual elements. |
public getView( ) : MVC_View |
Returns a prepared and loaded view instance of the renderer. Each individual renderer keeps its own instance of view. Thus, if needed, additional parameters and values can be passed to view scripts using this instance. |
public getWidth( ) : array|null |
Returns the set widths of the element. |
public setWidth( array $width ) : void |
Sets the width of the element. |
public setWidthCssClassesCreator( callable $width_css_classes_creator ) : void |
Sets the creator that transforms the width settings of the element to CSS classes. This is directly related to the display of the element, so the builder settings can be found in the view scripts of the elements themselves. For example, it takes the following form:
$renderer->setWidthCssClassesCreator(
|
public getWidthCssClassesCreator( ) : ?callable |
Returns the CSS class creator according to the width settings. See the setWidthCssClassesCreator method. |
public addJsAction( string $event, string $handler_code ) : static |
It allows to add event handler and JavaScript calls to the element. Let's see an example from practice. In the administration in user management there is an option to filter users by role. The filter is automatically sent after selection:
$filter_form
So: from the form we get an instance of the corresponding field, from the field we get a render instance of the input element itself (in this case Select) and we add an event handler to it.Please note that the method returns a render instance. It is therefore possible to call other render methods directly - for example to chain the renderer parameter settings, or to display the item directly. Ideally this method should be called in the view where the form is displayed, because this is related to the frontend logic. |
public getJsActions( ) : array |
Returns the set event handlers. See method addJsAction. |
public setBaseCssClass( string $base_css_class ) : static |
Sets the base CSS class (or classes - usually separated by a space character) of the element. Since this is a frontend appearance issue, this call should be made in the view script of the element. |
public getBaseCssClasses( ) : array |
Returns the base CSS of the element class. See method setBaseCssClass. |
public addCustomCssClass( string $class ) : static |
Adds one optional CSS element class. The method can be called repeatedly - add any number of optional classes. The method can be used in the view in which the form is displayed. |
public getCustomCssClasses( ) : array |
Returns a list of optional CSS classes. See the addCustomCssClass method. |
public getWidthCssClasses( ) : array |
Generates CSS classes for determining the width of the element (see the setWidthCssClassesCreator method) and returns a list of them in the form of an array. |
public getCssClasses( ) : array |
Returns a list of all CSS classes that belong to the element according to all settings. The list is returned as an array. |
public addCustomCssStyle( string $style ) : static |
Allows you to add an optional CSS style to the element if needed. It is possible to call the method repeatedly. The method can be used in the view in which the form is displayed. |
public getCssStyles( ) : array |
Returns a list of optional CSS styles. See the addCustomCssStyle method. |
public setDataAttribute( string $attr, string $value ) : static |
Allows the element to set data-attributes. Thus: data-something="SomeValue". The method can be used in the view in which the form is displayed. |
public unsetDataAttribute( string $attr ) : static |
Unsets the data-attribute setting. See the setDataAttribute method. |
public getDataAttributes( ) : array |
Returns a list of all set data-attribute. See the setDataAttribute method. |
public setCustomTagAttribute( string $attr, string $value ) : static |
It allows to set any attribute of the tag of the element. The method can be used in the view in which the form is displayed. |
public unsetCustomTagAttribute( string $attr ) : static |
Unset the optional setting of the element tag attribute. See the setCustomTagAttribute method. |
public getCustomTagAttributes( ) : array |
Returns the current optional attribute settings for the element tag. See the setCustomTagAttribute method. |
public generateTagAttributes( ) : array |
According to the current settings, it generates all the attributes of the element tag and returns them in the form of an associated array. |
public renderTagAttributes( ) : string |
According to the current settings, it generates all the attributes of the element tag and also generates a string that can be displayed. |