Формы в symfony 1.1 | Participants
|
- Statistics
- Participants
- Translate into Russian
- Translation result
- 98% translated in draft. Almost done, let's finish it!
If you do not want to register an account, you can sign in with OpenID.
Формы в symfony 1.1 | ||
A form is made of fields like hidden inputs, text inputs, select boxes, and checkboxes. This chapter introduces you to creating forms and managing form fields using the symfony forms framework. | Форма состоит из полей, таких, как скрытые поля, текстовые поля, выпадающие списки, чекбоксы. Эта глава познакомит вас с созданием форм и управлением полями с помощью фреймворка форм symfony. | |
Symfony 1.1 is required to follow the chapters of this book. You will also need to create a project and a frontend application to keep going. Please refer to the introduction for more information on symfony project creation. | Для выполнения упражнений из книги требуется Symfony 1.1. Кроме того, для дальнейшей работы вам нужно будет создать проект и приложение. Для более полной информации о создании проекта, читайте Введение. | |
Before we start | ||
We will begin by adding a contact form to a symfony application. | Начнём с добавления формы обратной связи к приложению. | |
Figure 1-1 shows the contact form as seen by users who want to send a message. | На рисунке 1-1 изображена форма обратной связи так, как её видит пользователь. | |
Figure 1-1 - Contact form | ||
Contact form | ||
We will create three fields for this form: the name of the user, the email of the user, and the message the user wants to send. We will simply display the information submitted in the form for the purpose of this exercise as shown in Figure 1-2. | Создадим три поля: имя пользователя, его email и сообщение, которое он хочет отправить. Для выполнения упражнения мы просто отобразим информацию, переданную формой, как показано на рисунке 1-2. | |
Figure 1-2 - Thank you Page | ||
Thank you page | ||
Figure 1-3 - Shows the interaction between the application and the user. | Рисунок 1-3 показывает процесс взаимодействия между приложением и пользователем. | |
Figure 1-3 - Interaction with the User | ||
Interaction with the user schema | ||
Widgets | ||
sfForm and sfWidget Classes | ||
Users input information into fields which make up forms. In symfony, a form is an object inheriting from the sfForm class. In our example, we will create a ContactForm class inheriting from the sfForm class. sfForm is the base class of all forms. sfForm makes it easy to manage the configuration and the life cycle of your forms. | Пользователи вводят информацию в поля, составляющие форму. Форма в symfony — это объект, наследующий класс sfForm. В нашем примере мы создадим класс ContactForm, наследующий класс sfForm. sfForm — это базовый класс для всех форм. sfForm облегчает управление конфигурацией и жизненным циклом ваших форм. | |
sfForm is the base class of all forms and makes it easy to manage the configuration and life cycle of your forms. | sfForm — это базовый класс для всех форм, облегчающий управление конфигурацией и жизненным циклом ваших форм. | |
You can start configuring your form by adding widgets using the configure() method. | Настройку формы можно начать с добавления виджетов в методе configure(). | |
A widget represents a form field. For our form example, we need to add three widgets representing our three fields: name, email, and message. Listing 1-1 shows the first implementation of the ContactForm class. | Виджет представляет поле формы. Для формы нашего примера добавим три виджета, представляющих ее поля: имя, email и сообщение. На листинге 1-1 показана первая реализация класса ContactForm. | |
Listing 1-1 - ContactForm class with three fields | ||
// lib/form/ContactForm.class.php | ||
class ContactForm extends sfForm | ||
{ | ||
public function configure() | ||
{ | ||
$this->setWidgets(array( |
© sensiolabs. License: GFDL license

— Этот абзац повторяет два предложения предыдущего — Enlightened