An open API service indexing awesome lists of open source software.

https://github.com/fefe33/php-functions


https://github.com/fefe33/php-functions

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

PHP functions for writing HTML






Table class




  1. call the constructor:


    $mytable = new Table([<titleA>, <titleB>], [[<value_A1>,< value_A2>],[<value_B1>,<value_B2>],...);


  2. apply styles


    $mytable->style(<element_or_set>,<inline_css>);


  3. valid elements and sets of elements include:



    • table --> which applies to the html table wrapper

    • head --> which applies to the thead wrapper

    • body --> which applies to the tbody wrapper

    • rows --> which applies to all of the rows (tr) contained in the generated table

    • cells --> which applies to all of the individual cells contained




  4. return the HTML


    $mytable->write();





Form class




  1. call the constructor:


    $myform = new Form(<formID>, <action>, <method>);


  2. add inputs


    methods:


    • for text based inputs:



      $myform->text_input($name, $type, $attributes)

      where valid types include:

      ['text', 'search', 'email', 'password', 'tel', 'url']


    • for fieldsets:



      $myform->fieldset($name, $label, $selection)

      where $selection is in the following format: array('label'=>'value', 'label'=>'value', ...]



    • for range sliders:
      $myform->range_input($name,$label,$min,$max,$step);


    • for numeric inputs:
      $myform->numeric_input($name,$label,$min,$max,$step)



    • for datetime inputs:
      $myform->datetime_input($name, $label, $type)



      where valid types include ['time', 'date', 'datetime-local', 'month']


    • for submit buttons:

      $myform->submit_input($innerText, $is_button, $attr)

      , where $innertext is the text either as the value attribute when its not a button or the inner text when it is.




    • for numeric inputs:

      $myform->numeric_input($name,$label,$min,$max,$step)




  3. return the HTML:




    $myform->write($break);

    where $break is a boolean value determining whether or not to add line breaks between elements




id structure in returned HTML


IDs are all based on the original formID provided in the constructor. each input within the form has an id whose syntax is as such: $formID-<int> where the integer is the index of the input relative all the others in the form (whose order is determined by the order in which one calls the methods). radios contained in fieldsets have ids in a different syntax: formID-<int>-Name-<int>-. the first int is the index of the fieldset relative to the form, the second is the index of the radio-element relative to the fieldset.



see file example.php for more detailed examples of how to use the different methods.