Jump to content
Sign in to follow this  
IPBDesign

Forms.php

Recommended Posts

IPBDesign    122
IPBDesign

Please login or register to see this link.



Please login or register to see this link.

Forms.php


Any one who follows me over on IPS knows I have had many complaints about the forms and form helpers. Tired of sounds of crickets chirping while waiting for IPS to make improvements or take in considerations from the community, I built this class file for applications. 

 

Usage:

Hidden Content

    Give reaction to this post to see the hidden content.

( after $form, all the parameters are the same that you would find for \IPS\Helpers\Form\__construct method, but most of the time you will only need to set the $elements, $instancename is if you have multiple forms on the same page).

$elements:

tab, header, sidebar:

'type' = tab|header|sidebar
'name' =  used for all these to create them, if it is a lang/string, this is what is passed to the appropriate form command.

example:

Hidden Content

    Give reaction to this post to see the hidden content.

separator:

'type' = 'separator'

example:

Hidden Content

    Give reaction to this post to see the hidden content.

message: ->addMessage( $lang, $css='', $parse=TRUE, $_id=NULL)

'type' = 'message'
'msg' = this options is require for this type, the message you want to display

optional:

'css' = any additional css classes
'parse' = default is true, set to false if msg is an already parsed lang string
'id' = id of the element, default is null

Example:

Hidden Content

    Give reaction to this post to see the hidden content.

helper:

required:

'name' = name of the element
'class' = IPS Form Help Class (without the \IPS\Helpers\Form portion) or a FQN for a custom class.

optional:

'default' = the default value
'required' = is it required or not
'options' = an array of options for the class (identical to how options are set for form helpers)
'validation' = validation method, can use a closure here, identical to how its set on the form helper.
'prefix' = prefix for the form helper
'suffix' = suffix for the form helper
'id' = id for the form helper (if not set, the class will automatically configure name parameter with js_ prepend to it)
'skip_id' = (bool) if 'id' isn't set, and you want it not to set it to js_name
'label' = a lang string to use as the label instead of 'name'
'description' => a lang string to use as an alternative description
'appearRequired' => (bool) make the form helper appear required.
 

Example:

Hidden Content

    Give reaction to this post to see the hidden content.

dummy: ->addDummy( $langKey, $value, $desc='', $warning='', $id='' )

Required:

'type' = 'dummy'
'name' = name of the element
'default' = value that will be display

Optional:

'desc' = description
'warning' = warning
'id' = html id (if not set, js_$name is used)

Example:

Hidden Content

    Give reaction to this post to see the hidden content.

html: ->addHtml( $html )

Required:

'type' = 'html'
'html' = the html to display

Example:

Hidden Content

    Give reaction to this post to see the hidden content.

Matrix: ->addMatrix( $name, $matrix )

Required:

'type' = 'matrix'
'matrix = must be an instance of \IPS\Helpers\Form\Matrix
'name' = elements name.

Example:

Hidden Content

    Give reaction to this post to see the hidden content.

i() method:

Hidden Content

    Give reaction to this post to see the hidden content.

the instantiation method is pretty straight forward, you pass the array of elements to it, if you have multiple forms on the page, you can give the instance a name. if you have a form object already (like in nodes) just pass it Forms, the other parameters are for creating a new form, same parameters as \IPS\Form.

 

Bringing it all together:

Hidden Content

    Give reaction to this post to see the hidden content.

this will return an instance of \IPS\Form. 

Hidden Content

    Give reaction to this post to see the hidden content.

Hidden Content

    Give reaction to this post to see the hidden content.


  • Submitter

    Please login or register to see this link.

  • Submitted
    03/13/2017
  • Category

    Please login or register to see this link.

 

Share this post


Link to post
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×