我是cakephp的新手并试图用它编写一个简单的应用程序,但是我遇到了一些表单验证问题.
我有一个名为"Person"的模型,它有很多"PersonSkill"对象.要向一个人添加"PersonSkill",我已将其设置为调用这样的URL:
HTTP://本地主机/ MyApp的/ person_skills /添加/为person_id:3
我一直在通过person_id,因为我想显示我们为其添加技能的人的姓名.
我的问题是如果验证失败,则person_id参数不会持久保存到下一个请求,因此不会显示此人的姓名.
控制器上的add方法如下所示:
function add() {
if (!empty($this->data)) {
if ($this->PersonSkill->save($this->data)) {
$this->Session->setFlash('Your person has been saved.');
$this->redirect(array('action' => 'view', 'id' => $this->PersonSkill->id));
}
} else {
$this->Person->id = $this->params['named']['person_id'];
$this->set('person', $this->Person->read());
}
}
Run Code Online (Sandbox Code Playgroud)
在我的person_skill add.ctp中,我设置了一个隐藏字段,其中包含person_id,例如:
echo $form->input('person_id', array('type'=>'hidden','value'=>$person['Person']['id']));
Run Code Online (Sandbox Code Playgroud)
有没有办法在表单验证失败时持久化person_id url参数,或者是否有更好的方法来完成我完全缺失的?
任何建议将不胜感激.
我正在尝试使用Maven设置一个项目,并且我对如何在生成的war文件中包含一些需要解包的第三方依赖项感到困惑.
我的项目包含一些自定义的ColdFusion代码,并包含Java依赖项,包括打包为war文件的ColdFusion.然后我试图包含一些第三方ColdFusion代码,我已经将其安装在我的maven资源库中打包为jar,但实际上我想在生成的war文件中将其解压缩.这就是我对第三方图书馆的解压缩.我真的希望在战争结束之前完成这项任务,以便我可以使用战争:在开发过程中爆炸.
目前我的pom.xml看起来像这样:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-webapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-webapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- This is the war overlay -->
<dependency>
<groupId>com.adobe.coldfusion</groupId>
<artifactId>coldfusion</artifactId>
<version>9.0.1</version>
<type>war</type>
<scope>runtime</scope>
<optional>false</optional>
</dependency>
<!-- This is the 3rd party ColdFusion dependency -->
<dependency>
<groupId>org.corfield</groupId>
<artifactId>fw1</artifactId>
<version>1.2RC2A</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>my-webapp</finalName>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
通过修改构建部分,我有点做了我想要的事情,如下所示:
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.corfield</groupId>
<artifactId>fw1</artifactId>
<version>1.2RC2A</version>
<type>jar</type> …
Run Code Online (Sandbox Code Playgroud)