Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created December 22, 2008 17:28
Show Gist options
  • Save ashgti/39062 to your computer and use it in GitHub Desktop.
Save ashgti/39062 to your computer and use it in GitHub Desktop.
- $f = new form($this->parser, '/',$user) do
%p
= $f->input('name')
<?php
class form {
protected $parser;
protected $object;
function __construct($parser, $url, $object) {
$this->parser = $parser;
$this->object = $object;
ob_start();
$this->parser->setSource("%form\{:action=\"#\" :method=>\"post\" :accept-charset =>\"utf-8\"}")->display();
}
function input($name) {
$parser_string = "%input\{:name => \"{$name}\"";
if ($this->object->get($name))
$parser_string .= ' :value => "'.$this->object->get($name).'"';
$parser_string .= '}';
$this->parser->setSource($parser_string)->display();
}
function __destruct() {
?>
<p><input type="submit" value="Continue →" /></p>
</form>
<?php
echo ob_get_clean();
}
}
?>
<form action="/" method="post" accept-charset="utf-8">
<p>
<input name="name" value="<?php echo $user->get("name") ?>" />
</p>
<p><input type="submit" value="Continue →" /></p>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment