Skip to content

Instantly share code, notes, and snippets.

@tedkulp
Created May 1, 2011 02:37
Show Gist options
  • Save tedkulp/950195 to your computer and use it in GitHub Desktop.
Save tedkulp/950195 to your computer and use it in GitHub Desktop.
Silly Ajax Demo w/ Silk
{* app/views/test/_form.tpl *}
{$form->render()}
{* app/views/test/index.html.tpl *}
<div id="form_me">
{$controller->renderPartial('_form')}
</div>
{* app/views/test/index.js.tpl *}
$('#form_me').html({partial name="_form" js=true});
<?php
# app/controllers/TestController.php
use \silk\action\Controller;
use \silk\form\Form;
class TestController extends Controller
{
function index()
{
$form = new Form('test_form', array('remote' => true));
$fs = $form->addFieldSet('field_set', array('legend' => 'Config Options'));
$fs->addField('TextBox', 'field1', array());
$form->addButton('Submit', array('disable-with' => 'Submitting...'));
if ($form->isPosted())
{
$form->fillFields();
if (!endsWith($fs['field1']->value, 'was here'))
$fs['field1']->value .= ' was here';
}
$this->set('form', $form);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment