Skip to content

Turaylon/autoform-spark

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autoform is a library that takes the hassle out of creating html forms. It can generate entire forms based on a table or sql query in your database, with all validation code in place. If you’re not basing your form an a DB table, that's fine too - you can build a form easily with a few simple lines.

Some Basic Usage

$this->load->spark('autoform/[version]');

$this->autoform->table('my_table');
// or you can use: $this->autoform->sql($query_result_obj);

// remove some unwanted fields
$this->autoform->remove(array('unwanted_field','another_unwanted_field'));

// change some attributes of some fields
$this->autoform->set('email', array('type'=>'email', 'class'=>'classname', 'required'=>'required'));
$this->autoform->set('name', array('value'=>$name));

// a new field thats not from the database
$this->autoform->add(array('name'=>'new_field', 'value'=>'my Value', 'type'=>'select', 'options'=>array('option 1'=>'First option', 'option 2'=>'second option')));

echo $this->autoform->generate('form/test');


// or output the form fields separately
echo $this->autoform->open('form/test', array('id'=>'form'), FALSE); // third parameter sets the form as multipart

// if this parameter is left empty, all fields are returned in the order they were created. 
echo $this->autoform->fields(array('email', 'name'));

echo $this->autoform->field('id');

// add and print at the same time
echo $this->autoform->add(array('type'=>'text','name'=>'example'));

// add the form subtmit button(s)
echo $this->autoform->buttons();

echo $this->autoform->close();

Note: the value will always be overwritten to the value posted if the form fails validation.

Install autoform and look at ./sparks/autoform/[version]/docs/autoform.html for more in depth documentation.

Change Log

  • 3.8.2 -- tidy up misc code & fix some php5.4 warnings -- the $action parameter is now optional (submits to the current url by default) -- fix an error in the fields() method. -- enable the formatting of date fields via a 'format' attribute. -- The get() method now returns the field value by default, instead of false. -- add support for boolean attributes (required, autofocus, etc..) eg: array('autofocus'=>TRUE). -- add ability to pass an array of field id's to the set() method. -- add a buttons() method. This sets/gets the submit button markup.

  • 3.8.1 -- correct & update documentation.

  • 3.8.0 -- added wrap_all method. -- bug fixes

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%