The Wiki documentation on pnForms seems really weak and all the pnForm plugins in the pnRender/plugin/ directory do not explain themselves to me. Also I haven't found any example module using the pnForms engine.
I'm trying to at least do a proof of concept and right now I have the following code in the pnuser.php:
Code
<?php
class HelloWorld_user_editHandler
{
var $name;
function initialize(&$render)
{
$data['name'] = 'Put your name here';
$render->assign($data);
return true;
}
function handleCommand(&$render, &$args)
{
if ($args['commandName'] == 'update')
{
if (!$render->pnFormIsValid())
return HelloWorld_user_view();
$data = $render->pnFormGetValues();
// ... ???
}
return true;
}
}
function HelloWorld_user_main()
{
return HelloWorld_user_edit();
}
function HelloWorld_user_edit()
{
$render = FormUtil::newpnForm('HelloWorld');
return $render->pnFormExecute('HelloWorld_user_edit.html', new HelloWorld_user_editHandler());
}
?>
class HelloWorld_user_editHandler
{
var $name;
function initialize(&$render)
{
$data['name'] = 'Put your name here';
$render->assign($data);
return true;
}
function handleCommand(&$render, &$args)
{
if ($args['commandName'] == 'update')
{
if (!$render->pnFormIsValid())
return HelloWorld_user_view();
$data = $render->pnFormGetValues();
// ... ???
}
return true;
}
}
function HelloWorld_user_main()
{
return HelloWorld_user_edit();
}
function HelloWorld_user_edit()
{
$render = FormUtil::newpnForm('HelloWorld');
return $render->pnFormExecute('HelloWorld_user_edit.html', new HelloWorld_user_editHandler());
}
?>
The edit template looks like this:
Code
<!--[pnForm]-->
<!--[pnFormValidationSummary]-->
<!--[pnFormLabel for=name text="Name"]-->:
<!--[pnFormTextInput id=name maxLength=30]--><br/>
<!--[pnFormButton commandName="update" text="Update"]-->
<!--[pnFormButton commandName="cancel" text="Cancel"]-->
<!--[/pnForm]-->
<!--[pnFormValidationSummary]-->
<!--[pnFormLabel for=name text="Name"]-->:
<!--[pnFormTextInput id=name maxLength=30]--><br/>
<!--[pnFormButton commandName="update" text="Update"]-->
<!--[pnFormButton commandName="cancel" text="Cancel"]-->
<!--[/pnForm]-->
This displays a label, a prefilled text entry field and two buttons. But when clicking submit nothing happens regardless of what I put in the place of the dots and question marks.
How do I now display the input maybe through a function HelloWorld_user_view()?
How exactly do all the other plugins work, especially the often needed like pnFormDropdownList, pnFormIntInput, pnFormCheckbox, pnFormImageButton, pnFormUploadInput and what are the pnFormTabbedPanel, pnFormTabbedPanelSet and pnFormVolatile blocks?
edited by: come, Oct 29, 2006 - 10:26 PM
