cakephp application development phần 8

Các kịch bản bây giờ sẽ yêu cầu nếu chúng ta muốn xây dựng bộ điều khiển của chúng tôi tương tác. Nhập n để bỏ qua nướng tương đó, các giao diện điều khiển nướng sẽ yêu cầu nếu nó phải bao gồm một số phương pháp CRUD cơ bản trong bộ điều khiển của chúng tôi. Nhập y để đi cho nó. | Simpo PDF Merge and Split Unregistered Version - http Chapter 9 Adding Forms to Add New Questions and Answers With our application we can view all the questions we can view all the answers to a question and we have even added a cool layout for our application. But we still cannot do a very important task. We still cannot add a new question or add a new answer. That is exactly what we are going to do in this section. We are going to add a form to the home action that will be able to add a new question to Quickwall. And to add a new answer we will also be adding a new form to the show action. So without any delay let s go and see how to do that. Time for Action 1. Since we will be using the home action for both displaying all the questions and also to add a new question add the following code to the home action of the Questions controller function home if empty this- data this- Question- create if this- Question- save this- data this- Session- setFlash Your Question has been added this- redirect array action home null true else this- Session- setFlash The Question could not be saved. Please try again. this- Question- recursive 1 this- set questions this- Question- find all 2. To display the form that will be used to add a new question add the following code to the top of the view file of the home action. As we already know the view file is quickwall app views questions . php e form- create Question array action home fieldset label for QuestionQuestion class questionlabel span Your Question span label php e form- text question array class fullwidth span class big span label for QuestionQuestioner class questionerlabel spa 215 Simpo PDF Merge and Split Unregistered Version - http Making Quickwall The Basics n Your Name span label php e form- text questioner array class halfwidth php e form- submit Post Your Question array div false class submitbutton fieldset php e form- end php if empty questions p class no_answer No Questions

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
200    160    23    02-05-2024
11    62    1    02-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.