Torn - form handling for Jelly. No longer maintained.
PHP JavaScript ActionScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
classes
config
media
messages
views/torn/field
README.md
init.php

README.md

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() ?>