Otóż, mój problem polega na tym, że filtry typu: Alpha, Digist, Int, itd. nie pwodują żadnego filtrowania (przepuszczają wszystko co wpiszę w kontrolce). Natomiast filtr StringTrim działa poprawnie. Prosiłbym o pomoc w ustaleniu źródła błędu.
Poniżej przedstawiam strukturę mojego projektu oraz zawartość plików.
CODE
zadanie11
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | |-- ErrorController.php
| | |-- IndexController.php
| |-- forms
|-- RegisterForm.php
|-- layouts
|-- scripts
|-- layout.phtml
|-- models
| |-- views
| |-- helpers
| |-- scripts
| |-- error
| |-- index
| |-- index.phtml
|-- next.phtml
|-- library
|-- public
| |-- .htaccess
| |-- index.php
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | |-- ErrorController.php
| | |-- IndexController.php
| |-- forms
|-- RegisterForm.php
|-- layouts
|-- scripts
|-- layout.phtml
|-- models
| |-- views
| |-- helpers
| |-- scripts
| |-- error
| |-- index
| |-- index.phtml
|-- next.phtml
|-- library
|-- public
| |-- .htaccess
| |-- index.php
application.ini
CODE
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.params.displayExceptions = 1
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.params.displayExceptions = 1
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
indexController.php
CODE
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
$this->form = new forms_RegisterForm();
}
public function indexAction()
{
// action body
if ($this->_request->isPost())
{
$formData = $this->_request->getPost();
if ($this->form->isValid($formData))
{
return $this->_forward('next');
}
else
{
$this->form->populate($formData);
}
}
$this->view->form = $this->form;
}
public function nextAction()
{
// action body
$this->view->dane = $this->_request->getPost();
$this->view->title = "Poprawne";
}
}
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
$this->form = new forms_RegisterForm();
}
public function indexAction()
{
// action body
if ($this->_request->isPost())
{
$formData = $this->_request->getPost();
if ($this->form->isValid($formData))
{
return $this->_forward('next');
}
else
{
$this->form->populate($formData);
}
}
$this->view->form = $this->form;
}
public function nextAction()
{
// action body
$this->view->dane = $this->_request->getPost();
$this->view->title = "Poprawne";
}
}
RegisterForm.php
CODE
<?php
class forms_RegisterForm extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
}
public function init()
{
/* Form Elements & Other Definitions Here ... */
$this->setMethod('post');
$this->setName('register_formularz');
//Wprowadź imię
$this->addElement('text', 'imie', array(
'label' => 'Podaj imie:',
'required' => true,
'size' => '30',
'filters' => array('Digits'),
'validators' => array('NotEmpty')
));
// add the submit button
$this->addElement('submit', 'submit', array(
'label' => 'wybierz',
));
}
}
class forms_RegisterForm extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
}
public function init()
{
/* Form Elements & Other Definitions Here ... */
$this->setMethod('post');
$this->setName('register_formularz');
//Wprowadź imię
$this->addElement('text', 'imie', array(
'label' => 'Podaj imie:',
'required' => true,
'size' => '30',
'filters' => array('Digits'),
'validators' => array('NotEmpty')
));
// add the submit button
$this->addElement('submit', 'submit', array(
'label' => 'wybierz',
));
}
}
index.phtml
CODE
<div>
<?php echo $this->title?>
<?php echo $this->form ?>
</div>
<?php echo $this->title?>
<?php echo $this->form ?>
</div>
next.phtml
CODE
<h1><?php echo $this->escape($this->title); ?></h1>
<div>
<?php foreach($this->dane as $x)
echo "<p>$x</p>"?>
</div>
<div>
<?php foreach($this->dane as $x)
echo "<p>$x</p>"?>
</div>
index.php
CODE
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../application'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// Umożliwia ładowanie automatyczne klas
require_once "Zend/Loader/Autoloader.php";
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
// Ustawia bazowy url w kontrolerze
//Zend_Controller_Front::getInstance()->setBaseUrl("/~pai/zadanko11/public");
$application->bootstrap()
->run();
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../application'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// Umożliwia ładowanie automatyczne klas
require_once "Zend/Loader/Autoloader.php";
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
// Ustawia bazowy url w kontrolerze
//Zend_Controller_Front::getInstance()->setBaseUrl("/~pai/zadanko11/public");
$application->bootstrap()
->run();