我正在尝试为Db_NoRecordExists验证器使用"exclude"选项,因为当我"编辑"该元素时,它总是像往常一样将我返回"重复"错误.
我的目的是告诉表单保留从Controller传递给表单本身的值...
这是控制器:
public function editAction()
{
$id = $this->getRequest()->getParam('id');
$pagesMapper = new Application_Model_PagesMapper();
$form = new Application_Form_PageEdit();
$form->populate($pagesMapper->fetchId($id, true));
if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
//... cut ...
}
}
$this->view->form = $form;
}
Run Code Online (Sandbox Code Playgroud)
这是表格:
class Application_Form_PageEdit extends Zend_Form
{
public function init()
{
$commonFilters = array('StringTrim');
$commonValidators = array('NotEmpty');
$this->setMethod('post')->setAction('/admin-page/edit');
$id = new Zend_Form_Element_Hidden('id');
$pid = new Zend_Form_Element_Hidden('pid');
$keyname = new Zend_Form_Element_Text('keyname');
$keyname->setLabel('Keyname')
->setRequired(true)
->addFilters($commonFilters)
->addFilter('StringToLower')
->addFilter('Word_SeparatorToDash')
->addValidator('Db_NoRecordExists', false, array(
'table' => 'pages',
'field' => 'keyname',
'exclude' => …
Run Code Online (Sandbox Code Playgroud) 我使用DomDocument生成一些非标准标记HTML,结果如下:
/* Input HTML
<div id="toobar_top">
<widget id="flag_holder"></widget>
<widget id="horizontal_menu"></widget>
</div>
<div id="header">
<widget name="header"></widget>
</div>
*/
Run Code Online (Sandbox Code Playgroud)
我想要做的是用一些有用的东西"翻译"每个小部件......它们是带有参数的简单占位符.
该类的函数提取是:
private function widgeter($doc) { //Give it an DomDocument HTML containing <widget> elements and will translate them into usable stuff
$this->_widgetList = $doc->getElementsByTagName($this->_widgetTransformTo);
foreach ($this->_widgetList as $widget) {
$data = array();
if ($widget->hasAttributes()) {
foreach ($widget->attributes as $attribute) {
$data[][$attribute->name] = $attribute->value;
// @TODO: Implements Widget Transformation
}
}
// Next 2 lines are just for debug
$string = serialize($data);
$newWidget = …
Run Code Online (Sandbox Code Playgroud) 简单的研究是: 蚁群模拟
我正在创建一个OO结构,它可以看到Anthill的类,Ant的类和整个模拟器的类.
现在我正在集思广益"如何"让蚂蚁"活着"......
我知道有这样的项目刚刚开始,但我正在集思广益,我不是在寻找一种刚刚准备好吃的菜.
我真的需要做一些测试来理解"什么是更好",在Python中,AFAIK Threads使用的内存少于进程.
当你开始模拟时"蚂蚁"必须做的只是:随机方向移动,如果他们找到食物 - >吃/带到蚁丘,如果他们发现另一只蚂蚁从另一个运送食物的蚁丘 - >攻击 - >收集食物 - >做必须做的事......等等......这意味着我必须在蚂蚁和整个环境中"分享"信息.
所以我重写:最好为每个Ant或其他东西创建一个进程/线程?
编辑:由于我的问题"什么是更好的",我提出了我收到的所有聪明的答案,我也对它们发表评论.经过我的测试,我会接受最好的答案.
我刚刚在 QT-Creator 中设计了我的 ui,由于主应用程序基于两个面板,我决定使用 StackedWidget 来“更改布局”而无需打开新窗口。
所以,我添加了一个名为:stackedWidget(默认)的 QTStackedWidget。
问题出在 mainwindow.cpp 中,我添加了一个自定义 SLOT,其中包含:
ui->stackedWidget->setCurrentIndex(1);
Run Code Online (Sandbox Code Playgroud)
当我构建它时,编译器说:
mainwindow.cpp:25: 错误:'Ui::MainWindow' 中没有名为 'stackedWidget' 的成员
ui->stackedWidget->setCurrentIndex(1);
~~ ^
同样在qt-creator本身中,我无法将信号附加到stackedWidget,因为它没有向我显示setCurrentIndex SLOT ...
有什么建议吗?
请注意,我是 C++ 的菜鸟,几年前我刚刚在 PyQt4 中使用了 Qt。
主窗口.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void showOtherPage();
void showMainPage();
};
#endif // MAINWINDOW_H
Run Code Online (Sandbox Code Playgroud)
主窗口.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
#include …
Run Code Online (Sandbox Code Playgroud) php ×2
c++ ×1
domdocument ×1
multiprocess ×1
python ×1
qt ×1
qt-creator ×1
qt5.2 ×1
resources ×1
simulation ×1
xhtml ×1
zend-form ×1