如何在 Atk4 中引用一个表单的填写与另一个表单的填写
我为登录用户制作了两种表格。第一个用于旅行信息(名称、简短描述),第二个用于当前用户旅行的不同地标(名称、描述)。是否可以将用户与填写旅行表格和将多次用于不同地标的地标表格“联系起来”。我有模型“trips”、“user”和“landmarks”以及各自的id,但我无法单独解决问题。
........................
我已经尝试过这个并且它发生了(感谢Romaninsh):
function page_trips(){
$this->api->stickyGET('id');
$id=$this->api->auth->get('id');
$f=$this->add('Form');
$f->addField('line','name')->setNotNULL();
$f->addField('Text','short_desc')->setNotNULL();
$f->setSource('trips');
$f->setConditionFromGET();
$f->dq
->set('user_id',$id);
$f->addSubmit('Next');
if($f->isSubmitted())
{
$f->update();
$f->js()->univ()->location($this->api->getDestinationUrl('../targets')
)
->execute();
}
}
现在我可以输入有关新旅行的信息并保存到表格与各自的用户 ID。剩下的任务是向当前行程添加不同的地标。
I have made two forms for logged users. The first one is for trip info (name, short description) and the second is for different landmarks (name, description) that are part of the trip of current user. Is it possible to "connect" the user with filling of trip form and the form for landmarks that is going to be used several times for different landmarks. I have the models "trips", "user" and "landmarks" with respective id's, but I can not solve the problem alone.
........................
I have tried this and it happened (thanks to Romaninsh):
function page_trips(){
$this->api->stickyGET('id');
$id=$this->api->auth->get('id');
$f=$this->add('Form');
$f->addField('line','name')->setNotNULL();
$f->addField('Text','short_desc')->setNotNULL();
$f->setSource('trips');
$f->setConditionFromGET();
$f->dq
->set('user_id',$id);
$f->addSubmit('Next');
if($f->isSubmitted())
{
$f->update();
$f->js()->univ()->location($this->api->getDestinationUrl('../targets')
)
->execute();
}
}
Now I can enter an info about new trip and save to table with respective user id. The rest of the task is to add different landmarks to current trip.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否是您正在寻找的,因为我使用了两页设计,您可能会使用另一页设计来添加/编辑/删除地标,但这也许会给您一些想法。
我在数据库中创建了三个表——trip、landmark和landmarktrip,其定义如下。
然后在wwwroot/website/lib/Model中创建模型如下
Landmark.php
Trip.php
LandmarkTrip.php
在wwwroot/中创建两个页面网站/页面,一个用于添加行程,一个用于添加行程,因为我不知道您使用的表单方法如何,您可以选择您想要查看详细信息的行程。
trips.php
itinerary.php
以及最后一个允许列表更改网格的文件
在 wwwroot/website/templates/js 中创建一个名为 trips_univ.js 的文件
trip_univ.js
现在,您可以使用 CRUD 来添加、编辑和删除行来创建行程。
然后进入行程页面,从下拉列表中选择行程,或者默认为最早的行程,并且可以添加、删除或编辑行程中的地标。
Not sure if it's what you are looking as i used a two page design and you would probably use another one to add/edit/delete landmarks but maybe this will give you some ideas.
I created a three tables in the database - trip, landmark and landmarktrip with the following definitions.
And then created models in wwwroot/website/lib/Model as follows
Landmark.php
Trip.php
LandmarkTrip.php
Created two pages in wwwroot/website/page, one to add the trips and one for the itinerary as i dont see how with the form approach you are using, you can select which trip you want to see the details of.
trips.php
itinerary.php
and one last file which allows the list to change the grid
Create a file called trips_univ.js in wwwroot/website/templates/js
trip_univ.js
So now, you can create trips using the CRUD to add, edit and delete rows.
Then go to the itinerary page to select a trip from the dropdown list or it defaults to the earliest trip and can add, remove or edit landmarks from the trip.
由于您已经部分解决了问题,我只需要添加一些有关如何将多个操作合并到表单中的注释。
这样,您可以在保存表单时创建多个模型。
As you have solved your problem partially, I just need to add some notes on how to incorporate multiple actions into the form.
This way you can create multiple models when the form is saved.