Для модуля forum создайте файлы, с помощью которых вы сможете посмотреть, как работать с формами в платформе Wad-er.
Контроллер – ext/forum/controllers/index.php:
if(!defined('SYS_BASE_PATH')) exit('Direct links are forbidden');
class forum_controllers_index extends common_controller
{
public function index($pars = '')
{
$model = new analytics_models_index($this->parser);
$this->addChild('analytics/breadcrumbs');
$this->addChild('analytics/searchform');
$this->addChild('analytics/languages');
$this->addChild('analytics/menu');
$this->addChild('analytics/topmenu');
$this->render();
}
public function add()
{
//post-значения
$this->name = (isset($this->request['name'])) ? $this->request['name'] : '';
$this->description = (isset($this->request['description'])) ? $this->request['description'] : '';
//наследуем wPrototype
$model = new forum_models_index();
foreach($model->fields->vars as $key => $sVal)
$model->fields->$key->val = 1;
$model->fields->objid->val = $this->name;
$model->fields->description->val = $this->description;
$this->errormessage = $model->insert();
$this->index();
}
}
Модель - ext/forum/models/index.php:
include_once(SYS_BASE_PATH.'main/classes/wprototype.class.php');
class forum_models_index extends wPrototype
{
public function __construct($objtype = '', $id = '')
{
$this->id = $id;
parent::__construct('sys_objects');
$this->extra_deleteAll_sql = "WHERE objid<>'0' ";
$this->translateLabels();
}
}
Представление - ext/forum/views/index.php (уберите лишние пробелы возле тегов):
< form id="topicform" action="< ? php print($parser- >makeUrl($parser- >pageId)); ? >" method="POST" name="topicform" onsubmit="return checkForm()" >
< table class="pageform" style="width: 100%;" border="0" >
< tbody >
< tr >
< td >< ? php print($parser- >gt('name')); ? >< span class="required" > *< /span >< /td >
< td >< input id="name" class="input" style="width: 400px;" type="text" name="name" value="< ? php print($name); ? >" / >< /td >
< /tr >
< tr >
< td valign="top" > < /td >
< td >< textarea name="description" id="description" >< ? php print($description); ? >< /textarea >< /td >
< /tr >
< /tbody >
< /table >
< br / > < ? php if($errormessage) { ? >
< center >
< div id="msgbox" > < /div >
< /center >
< ? php } else {
print "Форма успешно отправлена";
} ? > < br / > < input id="submitbutton" class="butsubmit" type="submit" value="< ? php print($parser- >gt('insert')); ? >" / >
< input id="action" type="hidden" name="action" value="add" / >
< /form >
Зайдите по адресу http://site.com/forum/index и протестируйте созданную форму. Так как пример тестовый, в поле «Название» можно вводить только латинские буквы.