TAILIEUCHUNG - PHP in Action phần 9

Các bộ lọc () phương pháp làm việc trên một đối tượng yêu cầu nguyên liệu. Đối tượng này không phải là dự định được sử dụng trực tiếp. bộ lọc () trả về TRUE nếu tất cả các biến phù hợp với tiêu chuẩn lọc. Thành công, chúng ta có thể có được một đối tượng yêu cầu mới, sạch, | Feature-revealing code. To make the code as readable as possible let s try to avoid making it too convenient. Hiding as much of the mechanics of the process as possible is tempting but the code will be more self-documenting if important steps in the process are explicit validating the form populating it and passing values into the template. Testable. A by-product of making the code more explicit is making it testable. We want to be able to replace important objects with mock objects. Typically this involves passing them into a constructor or other method. Putting generated elements into the HTML form Perhaps the greatest challenge of all in form handling is getting the form contents and the HTML markup to work together as a team. This is of course the same challenge as in other dynamic web pages but a typical form has a particularly high density of individual values to be inserted especially if there is client-side validation. Also the form speaks to a mixed audience since some of it is intended for the human user and some is not. We ll see what we can do using the simplest possible strategy and consider whether we need the HTML_QuickForm Renderer class. Manual template building The simplest way to insert elements of the form object into the template is the direct route. That means something like this using PHPTAL syntax span tal content form elements headline getLabel Headline this is sample text that PHPTAL removes span input type text name form elements headline getName value form elements headline getValue We can avoid making the paths this long if we want the example is just intended to illustrate the principle. Having a template getting the values from the form object and inserting them into the template is the basic way to do it. The alternative is passing the form object to the template. Do we need the renderer Given the popularity of HTML_QuickForm it s not surprising that we re not the only ones who have wanted to use it with a template engine. .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.