2014-03-24 23:12
浏览 37

Codeigniter - 从控制器传递数组,查看,然后传递到另一个控制器

I have a controller which handles the adding of records to a database. Sometimes these records require a couple of passwords to be entered, to "sign the record". Therefore, when the form is submitted, it is passed to a function in the controller called "getSignatures." This will load a view with inputs for the passwords needed. The users will then enter their passwords to "sign the document". This will then be passed to a function in the controller called "checkSignatures," which will call a function in the model to check the passwords.

However, I still need to pass through or save all the data from when the form is submitted.

I have tried using a global variable to save the form data, but when the checkSignatures function is called, it's called through a new controller. I also tried passing through the form data to the view, saving it in a hidden input and then passing it back through post but you can't save an array in a hidden input.

Any ideas would be great, and sorry for the long-winded question.

图片转代码服务由CSDN问答提供 功能建议

我有一个控制器来处理向数据库添加记录。 有时这些记录需要输入几个密码才能“签署记录”。 因此,在提交表单时,会将其传递给名为“getSignatures”的控制器中的函数。 这将加载一个视图,其中包含所需密码的输入。 然后,用户将输入他们的密码以“签署文档”。 然后将其传递给控制器​​中名为“checkSignatures”的函数,该函数将调用模型中的函数来检查密码。

但是,我仍然需要通过或保存 表单提交时的所有数据。

我尝试使用全局变量来保存表单数据,但是当调用checkSignatures函数时,它会通过新的控制器调用。 我还尝试将表单数据传递给视图,将其保存在隐藏的输入中,然后通过post传回,但是您无法将数组保存在隐藏的输入中。

任何 想法会很棒,并为这个冗长的问题感到抱歉。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxiangdiao6348 2014-03-24 23:15

    Try using sessions as described here. In particular you should look at CodeIgniter's flashdata.

    Sessions will be stored on the server for the entirety of the user's browsing session. This will let you access the data again. Flashdata is deleted after the next page load so they don't stick around for long.

    打赏 评论

相关推荐 更多相似问题