- Moderated by:
- Support
-
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
I'd like to use the pnForms engine, but can't quite grasp how to handle the input and go forth from there.
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());
}
?>
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]-->
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
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
Isn't there anyone who has a little experience with the pnForms framework? Does anyone know a module that uses it?
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Helper
- registered:
- July 2002
- Status:
- offline
- last visit:
- 07.09.08
- Posts:
- 245
come
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.
Yeah, pnForms is very much work in progress. I'm writing a HowTo/example module at the moment - and will soon start documenting the plugins.
Your code should be:
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 false;
$data = $render->pnFormGetValues();
// ... do what you want with the data the user entered (like updating the database)
}
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());
}
?>
Your HTML template seems correct.
Quote
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.
Nothing is supposed to happen - you must write the "happen" code your self - like for instance updating the database with the entered values.
Quote
How do I now display the input maybe through a function HelloWorld_user_view()?
You stored it in the DB and redirects to a normal rendered page that displays the stored data.
Quote
How exactly do all the other plugins work
Sorry, no docs yet.
After handling the "Update" command and updating the DB you should do a pnRedirect($URL) to a suitable page. -
- rank:
-
Helper
- registered:
- July 2002
- Status:
- offline
- last visit:
- 07.09.08
- Posts:
- 245
-
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
I see that there is a lot going on in the SVN regarding the pnForms engine. I'll try it out again shortly.
Thank you for your efforts.
--
greetings,
O. Encke
ASUS Notebook Forum
