Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

TdroL/kohana-jelly-torn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This module is no longer maintained.

Torn is a form generator for Jelly.

Requirements

Features

  • Extendable fields
  • Build-in flash uploader
  • Extended Jelly's File_Field to prevent from loosing uploaded file after validation fails
  • Garbage collector

Examples

Add Torn to submodules list in bootstrap.php before Jelly:

Kohana::modules(array(
	...
	'jelly-torn' => MODPATH.'jelly-torn',
	'jelly' => MODPATH.'jelly',
	...
));

Example - action (with file upload):

public function action_update()
{
	$post = Jelly::select('post', $this->request->param('id'));
	
	$torn = new Torn($post);
	
	$this->template->content->form = $torn;
	
	if($_POST)
	{
		try
		{
			$post->set($_FILES + $_POST); // remove "$_FILES +" if you won't upload files
			$post->save();
		}
		catch (Validate_Exception $e)
		{
			$torn->catch_errors($e);
		}
	}
}

Example - view:

<?php echo $form->open(NULL, Torn::$allow_upload) ?>

<?php if($form->has_errors()): ?>
<div class="errors">
	<h3>Errors</h3>
	<ul>
	<?php foreach($form->errors as $error): ?>
		<li><?php echo $error ?></li>
	<?php endforeach ?>
	</ul>
</div>
<?php endif ?>

<dl>
	<dt><?php echo $form->title->label() ?></dt>
	<dd>
		<?php echo $form->title->input() ?>
	</dd>
	
	<dt><?php echo $form->body->label() ?></dt>
	<dd>
		<?php echo $form->body->input() ?>
	</dd>
	
	<dt><?php echo $form->file->label() ?></dt>
	<dd>
		<?php echo $form->file->input() ?>
	</dd>
	
	<dt><?php echo $form->authors->label() ?></dt>
	<dd>
		<?php echo $form->authors->set_filename('custom_field_view')->input() ?>
	</dd>
	
	<dd><input type="submit" value="Update" /></dd>
</dl>

<?php echo $form->close() ?>

About

Torn - form handling for Jelly. No longer maintained.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published