NewgroupAction converted to extend FormAction

Had to change Action function 'prepare' to 'protected', as you can't
(of course) protect something that's been public in a parent class. The
other way around seems fine for PHP... Eventually all actions will have
protected 'prepare' (use execute/run)

A feature of the previously fixed initialization of Action classes, is
that we now have $this->scoped which is the current profile in use. As
of now that is always a local User, except the corresponding Profile
object.

Also, instead of calling 'showForm' everywhere, in case of an error we
just throw an exception of some sort and pass the message along there.

I've also introduced in FormAction the 'showInstructions' function in
order to get a unified instructions/info/error display method.

TODO: Improve info/error message handling, and what/when/where to show.
This commit is contained in:
Mikael Nordfeldth
2013-08-31 15:03:59 +02:00
parent 8d57fb7dc0
commit cfa699e445
3 changed files with 48 additions and 75 deletions

View File

@@ -82,6 +82,25 @@ class FormAction extends Action
return !$this->isPost();
}
public function showPageNotice()
{
$this->showInstructions();
if ($msg = $this->getError()) {
$this->element('div', 'error', $msg);
}
if ($msg = $this->getInfo()) {
$this->element('div', 'info', $msg);
}
}
/**
* Outputs the instructions for the form
*
* SHOULD overload
*/
public function showInstructions() {
}
public function showForm($msg=null, $success=false)
{
if ($success) {