ofFormConfirmPlugin
For example
1 Create Form class
<?php
class SampleForm extends sfForm
{
private static $sel = array(
1=>'A',
2=>'B'
);
public function configure()
{
$this->setWidgets(array(
'title' => new sfWidgetFormInput(),
'description' => new sfWidgetFormTextarea(),
'sel' => new sfWidgetFormSelectMany(array('choices'=>self::$sel)),
'crypto' => new sfWidgetFormCryptographp(),
'test' => new sfWidgetFormInputCheckbox()
));
$this->setValidators(array(
'title' => new sfValidatorString(array('max_length' => 255, 'required' => true)),
'description' => new sfValidatorString(array('required' => true)),
'crypto'=> new sfValidatorCryptographp(),
'sel'=> new sfValidatorPass(),
'test'=> new sfValidatorPass()
));
}
/**
* confirm table rows
*
* @return string
*/
public function confirm()
{
$conf = new ofFormConfirm($this, array(
'crypto'//disabled fields
));
return $conf->render();
}
}
2. Create Action
class sampleActions extends sfActions
{
/**
* Executes index action
*
* @param sfWebRequest $request A request object
*/
public function executeIndex($request)
{
$this->f = new SampleForm();
$this->f->getWidgetSchema()->setNameFormat("sample[%s]");
return ofFormConfirmPattern::standard($this->f, $this, "sample");
}
public function executeUpdate()
{
if(!$data = $this->getUser()->getFlash("sample"))
{
return sfView::ERROR;
}
//save data
//$item = new Item;
//$item->fromArray($data, BasePeer::TYPE_FIELDNAME);
//$item->save();
$this->f = new SampleForm();
$this->f->bind($data);
}
}
3 Create Templates
indexInput.php
<form action="<?php echo url_for($sf_context->getModuleName()."/index") ?>" method="post">
<table>
<?php echo $f ?>
</table>
<input type="submit" value="Submit" />
</form>
indexSuccess.php
<p>Are you sure?</p>
<table>
<?php echo $f->confirm() ?>
</table>
<?php echo button_to("OK", $sf_context->getModuleName()."/update") ?>
<?php echo button_to("Back", $sf_context->getModuleName()."/index") ?>
updateSuccess.php
Thank You
<table>
<?php echo $f->confirm() ?>
</table>