Skip to content

Commit a8c69e1

Browse files
Merge pull request #38 from punkah/forms
Forms page translation
2 parents 93086d3 + 329fe73 commit a8c69e1

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

content/docs/forms.md

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: forms
3-
title: Forms
3+
title: Űrlapok
44
permalink: docs/forms.html
55
prev: lists-and-keys.html
66
next: lifting-state-up.html
@@ -9,27 +9,27 @@ redirect_from:
99
- "docs/forms-zh-CN.html"
1010
---
1111

12-
HTML form elements work a little bit differently from other DOM elements in React, because form elements naturally keep some internal state. For example, this form in plain HTML accepts a single name:
12+
A HTML űrlap elemek kissé máshogy működnek a többi DOM elemhez képest Reactben, mert az űrlap elemek alapvetően egy saját belső állapotot tartanak nyilván. Például ez az űrlap szimpla HTML-ben egy nevet fogad be:
1313

1414
```html
1515
<form>
1616
<label>
17-
Name:
17+
Név:
1818
<input type="text" name="name" />
1919
</label>
2020
<input type="submit" value="Submit" />
2121
</form>
2222
```
2323

24-
This form has the default HTML form behavior of browsing to a new page when the user submits the form. If you want this behavior in React, it just works. But in most cases, it's convenient to have a JavaScript function that handles the submission of the form and has access to the data that the user entered into the form. The standard way to achieve this is with a technique called "controlled components".
24+
Amikor a felhasználó beküldi ezt az űrlapot, a HTML alapviselkedése miatt ez egy új oldalra fog navigálni. Ha ezt a viselkedést szeretnéd elérni Reactben, eleve működni fog. De a legtöbb esetben érdemesebb egy JavaScript függvényben lekezelni az űrlap beküldését, aminek hozzáférése van a felhasználó által bevitt adatokhoz. Ennek elérése általában az úgynevezett "kontrollált komponensek" módszerével lehetséges.
2525

26-
## Controlled Components {#controlled-components}
26+
## Kontrollált komponensek {#controlled-components}
2727

28-
In HTML, form elements such as `<input>`, `<textarea>`, and `<select>` typically maintain their own state and update it based on user input. In React, mutable state is typically kept in the state property of components, and only updated with [`setState()`](/docs/react-component.html#setstate).
28+
A HTML űrlap elemek, mint az `<input>`, `<textarea>` és `<select>`, általában fenntartják a saját belső állapotukat, amit felhasználói bevitel alapján változtatnak. A Reactben a módosítható állapotot általában a komponens állapotában tároljuk, és csak a [`setState()`](/docs/react-component.html#setstate) meghívásával változik.
2929

30-
We can combine the two by making the React state be the "single source of truth". Then the React component that renders a form also controls what happens in that form on subsequent user input. An input form element whose value is controlled by React in this way is called a "controlled component".
30+
Ezt a kettőt összekombinálhatjuk ha a React állapotot vesszük az "egyedüli igazságforrás"-ként. Így a React komponens, ami az űrlapot rendereli, azt is kontrollálja, hogy mi történik az űrlapban a felhasználói bevitel hatására. Egy beviteli elem, aminek az értékét ily módon a React kontrollál, "kontrollált komponens"-nek hívjuk.
3131

32-
For example, if we want to make the previous example log the name when it is submitted, we can write the form as a controlled component:
32+
Például ha azt szeretnénk hogy az előző példa kiírja a konzolra a nevet az űrlap beküldésekor, létrehozhatjuk az űrlapot egy kontrollált komponensként:
3333

3434
```javascript{4,10-12,24}
3535
class NameForm extends React.Component {
@@ -46,15 +46,15 @@ class NameForm extends React.Component {
4646
}
4747
4848
handleSubmit(event) {
49-
alert('A name was submitted: ' + this.state.value);
49+
alert('Ezt a nevet küldték be: ' + this.state.value);
5050
event.preventDefault();
5151
}
5252
5353
render() {
5454
return (
5555
<form onSubmit={this.handleSubmit}>
5656
<label>
57-
Name:
57+
Név:
5858
<input type="text" value={this.state.value} onChange={this.handleChange} />
5959
</label>
6060
<input type="submit" value="Submit" />
@@ -64,36 +64,36 @@ class NameForm extends React.Component {
6464
}
6565
```
6666

67-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/VmmPgp?editors=0010)
67+
[**Próbáld ki CodePenen**](https://codepen.io/gaearon/pen/VmmPgp?editors=0010)
6868

69-
Since the `value` attribute is set on our form element, the displayed value will always be `this.state.value`, making the React state the source of truth. Since `handleChange` runs on every keystroke to update the React state, the displayed value will update as the user types.
69+
Mivel a `value` attribútum be van állítva az elemen, a megjelenített érték mindig `this.state.value` lesz, ez teszi a React állapotot az egyéni igazságforrássá. Mivel a `handleChange` minden egyes billentyűleütéskor frissíti a React állapotot, a megjelenített érték is frissülni fog a felhasználó bevitele eredményeképpen.
7070

71-
With a controlled component, every state mutation will have an associated handler function. This makes it straightforward to modify or validate user input. For example, if we wanted to enforce that names are written with all uppercase letters, we could write `handleChange` as:
71+
Egy kontrollált komponensben minden állapotmódosításhoz hozzá kell rendelni egy eseménykezelő függvényt. Ez egyszerűvé teszi a felhasználó által bevitt adat módosítását vagy érvényesítését. Például ha szeretnénk biztosítani, hogy a nevek csupa nagybetűvel legyenek írva, így módosíthatjuk a `handleChange`-t:
7272

7373
```javascript{2}
7474
handleChange(event) {
7575
this.setState({value: event.target.value.toUpperCase()});
7676
}
7777
```
7878

79-
## The textarea Tag {#the-textarea-tag}
79+
## A textarea címke {#the-textarea-tag}
8080

81-
In HTML, a `<textarea>` element defines its text by its children:
81+
A HTML-ben a `<textarea>` tartalma a gyermeke által van definiálva:
8282

8383
```html
8484
<textarea>
85-
Hello there, this is some text in a text area
85+
Hellóka, ez itt némi szöveg egy szövegterületen
8686
</textarea>
8787
```
8888

89-
In React, a `<textarea>` uses a `value` attribute instead. This way, a form using a `<textarea>` can be written very similarly to a form that uses a single-line input:
89+
Reactben a `<textarea>` ehelyett egy `value` attribútumot használ. Így az űrlap, ami `<textarea>`-t használ, nagyon hasonló az egysoros beviteli mezőhöz:
9090

9191
```javascript{4-6,12-14,26}
9292
class EssayForm extends React.Component {
9393
constructor(props) {
9494
super(props);
9595
this.state = {
96-
value: 'Please write an essay about your favorite DOM element.'
96+
value: 'Írj egy esszét a kedvenc DOM elemedről.'
9797
};
9898
9999
this.handleChange = this.handleChange.bind(this);
@@ -105,15 +105,15 @@ class EssayForm extends React.Component {
105105
}
106106
107107
handleSubmit(event) {
108-
alert('An essay was submitted: ' + this.state.value);
108+
alert('Beküldtek egy esszét: ' + this.state.value);
109109
event.preventDefault();
110110
}
111111
112112
render() {
113113
return (
114114
<form onSubmit={this.handleSubmit}>
115115
<label>
116-
Essay:
116+
Esszé:
117117
<textarea value={this.state.value} onChange={this.handleChange} />
118118
</label>
119119
<input type="submit" value="Submit" />
@@ -123,22 +123,22 @@ class EssayForm extends React.Component {
123123
}
124124
```
125125

126-
Notice that `this.state.value` is initialized in the constructor, so that the text area starts off with some text in it.
126+
Figyeld meg, hogy a `this.state.value` a konstruktorban kerül inicializálásra, így a szövegterület már az elején tartalmazni fog némi szöveget.
127127

128-
## The select Tag {#the-select-tag}
128+
## A select címke {#the-select-tag}
129129

130-
In HTML, `<select>` creates a drop-down list. For example, this HTML creates a drop-down list of flavors:
130+
A HTML-ben a `<select>` egy legördülő menüt hoz elő. Ez a HTML például egy ízesítésekből álló legördülő menüt tartalmaz:
131131

132132
```html
133133
<select>
134134
<option value="grapefruit">Grapefruit</option>
135135
<option value="lime">Lime</option>
136-
<option selected value="coconut">Coconut</option>
137-
<option value="mango">Mango</option>
136+
<option selected value="coconut">Kókusz</option>
137+
<option value="mango">Mangó</option>
138138
</select>
139139
```
140140

141-
Note that the Coconut option is initially selected, because of the `selected` attribute. React, instead of using this `selected` attribute, uses a `value` attribute on the root `select` tag. This is more convenient in a controlled component because you only need to update it in one place. For example:
141+
Figyeld meg, hogy a Kókusz opció van kiválasztva alapból, mivel ez tartalmazza a `selected` attribútumot. A React a `selected` attribútum helyett a `value` attribútumot használja a gyökér `select` címkén. Ez így egyszerűbb egy kontrollált komponensben, mivel így csak egy helyen kell módosítani az értéket. Például:
142142

143143
```javascript{4,10-12,24}
144144
class FlavorForm extends React.Component {
@@ -163,12 +163,12 @@ class FlavorForm extends React.Component {
163163
return (
164164
<form onSubmit={this.handleSubmit}>
165165
<label>
166-
Pick your favorite flavor:
166+
Válaszd ki a kedvenc ízesítésedet:
167167
<select value={this.state.value} onChange={this.handleChange}>
168168
<option value="grapefruit">Grapefruit</option>
169169
<option value="lime">Lime</option>
170-
<option value="coconut">Coconut</option>
171-
<option value="mango">Mango</option>
170+
<option value="coconut">Kókusz</option>
171+
<option value="mango">Mangó</option>
172172
</select>
173173
</label>
174174
<input type="submit" value="Submit" />
@@ -178,33 +178,33 @@ class FlavorForm extends React.Component {
178178
}
179179
```
180180

181-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/JbbEzX?editors=0010)
181+
[**Próbáld ki CodePenen**](https://codepen.io/gaearon/pen/JbbEzX?editors=0010)
182182

183-
Overall, this makes it so that `<input type="text">`, `<textarea>`, and `<select>` all work very similarly - they all accept a `value` attribute that you can use to implement a controlled component.
183+
Alapvetően ezáltal mind az `<input type="text">`, `<textarea>` és `<select>` is hasonlóan működik - mindegyiknek van egy `value` attribútuma, amit használhatsz egy kontrollált komponens létrehozásához.
184184

185-
> Note
185+
> Megjegyzés
186186
>
187-
> You can pass an array into the `value` attribute, allowing you to select multiple options in a `select` tag:
187+
> Ha egy tömböt rendelsz a `value` attribútumhoz, akár több opciót is kiválaszthatsz egyszerre a `select` címkében:
188188
>
189189
>```js
190190
><select multiple={true} value={['B', 'C']}>
191191
>```
192192
193-
## The file input Tag {#the-file-input-tag}
193+
## A fájlbeviteli címke {#the-file-input-tag}
194194
195-
In HTML, an `<input type="file">` lets the user choose one or more files from their device storage to be uploaded to a server or manipulated by JavaScript via the [File API](https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications).
195+
A HTML-ben az `<input type="file">` segítségével a felhasználó kiválaszthat egy vagy több fájlt a saját gépéről a szerverre feltöltéshez vagy a JavaScript [Fájl API-val](https://developer.mozilla.org/hu/docs/Web/API/File/Fajlok_hasznalata_webes_alkalmazasokban) való manipuláláshoz.
196196
197197
```html
198198
<input type="file" />
199199
```
200200
201-
Because its value is read-only, it is an **uncontrolled** component in React. It is discussed together with other uncontrolled components [later in the documentation](/docs/uncontrolled-components.html#the-file-input-tag).
201+
Mivel ez csak olvasható értékkel rendelkezik, ez egy **kontrollálatlan** komponens. Erről a többi kontrollálatlan komponenssel együtt olvashatsz [később a dokumentációban](/docs/uncontrolled-components.html#the-file-input-tag).
202202

203-
## Handling Multiple Inputs {#handling-multiple-inputs}
203+
## Több bemenet kezelése {#handling-multiple-inputs}
204204

205-
When you need to handle multiple controlled `input` elements, you can add a `name` attribute to each element and let the handler function choose what to do based on the value of `event.target.name`.
205+
Ha több kontrollált `input` elemet is kezelned kell, hozzáadhatsz egy `name` attribútumot az egyes elemekhez, így az eseménykezelő függvény az `event.target.name` alapján tudja eldönteni, hogy mit csináljon.
206206

207-
For example:
207+
Például:
208208

209209
```javascript{15,18,28,37}
210210
class Reservation extends React.Component {
@@ -254,31 +254,31 @@ class Reservation extends React.Component {
254254
}
255255
```
256256

257-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/wgedvV?editors=0010)
257+
[**Próbáld ki CodePenen**](https://codepen.io/gaearon/pen/wgedvV?editors=0010)
258258

259-
Note how we used the ES6 [computed property name](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Object_initializer#Computed_property_names) syntax to update the state key corresponding to the given input name:
259+
Figyeld meg, hogy hogyan használtuk az ES6 [kiszámított mező név](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Object_initializer#Computed_property_names) szintaxist, hogy frissíteni tudjuk az állapotkulcsot, ami a megadott bemenet nevével egyezik meg:
260260

261261
```js{2}
262262
this.setState({
263263
[name]: value
264264
});
265265
```
266266

267-
It is equivalent to this ES5 code:
267+
Ez ekvivalens a következő ES5 kóddal:
268268

269269
```js{2}
270270
var partialState = {};
271271
partialState[name] = value;
272272
this.setState(partialState);
273273
```
274274

275-
Also, since `setState()` automatically [merges a partial state into the current state](/docs/state-and-lifecycle.html#state-updates-are-merged), we only needed to call it with the changed parts.
275+
Valamint, mivel a `setState()` automatikusan [összefésüli a részleges állapotot a jelenlegi állapottal](/docs/state-and-lifecycle.html#state-updates-are-merged), elég csak a megváltozott állapotot átadni.
276276

277-
## Controlled Input Null Value {#controlled-input-null-value}
277+
## Kontrollált bemenet null értéke {#controlled-input-null-value}
278278

279-
Specifying the value prop on a [controlled component](/docs/forms.html#controlled-components) prevents the user from changing the input unless you desire so. If you've specified a `value` but the input is still editable, you may have accidentally set `value` to `undefined` or `null`.
279+
A `value` megadása egy [kontrollált komponensen](/docs/forms.html#controlled-components) megakadályozza a felhasználót abban, hogy az engedélyünk nélkül változtassa meg a beviteli adatokat. Ha megadtál egy `value`-t, de a bemenet mégis szerkeszthető, valószínűleg véletlenül `undefined` vagy `null`-ra állítottad a `value`-t.
280280

281-
The following code demonstrates this. (The input is locked at first but becomes editable after a short delay.)
281+
A következő kódrészlet ezt demonstrálja. (A bemenet eleinte nem szerkeszthető, de egy rövid késleltetés után szerkeszthetővé válik.)
282282

283283
```javascript
284284
ReactDOM.render(<input value="hi" />, mountNode);
@@ -289,10 +289,10 @@ setTimeout(function() {
289289

290290
```
291291

292-
## Alternatives to Controlled Components {#alternatives-to-controlled-components}
292+
## Kontrollált komponens alternatívák {#alternatives-to-controlled-components}
293293

294-
It can sometimes be tedious to use controlled components, because you need to write an event handler for every way your data can change and pipe all of the input state through a React component. This can become particularly annoying when you are converting a preexisting codebase to React, or integrating a React application with a non-React library. In these situations, you might want to check out [uncontrolled components](/docs/uncontrolled-components.html), an alternative technique for implementing input forms.
294+
Néha nehézkes lehet kontrollált komponenseket használni, mivel minden lehetséges adatváltoztatási módhoz kell egy eseménykezelőt írnod és hozzá kell kötni az összes belső állapotot a React komponens állapotához. Ez különösen bosszantó lehet, amikor meglévő kódot kell átírni Reactbe, vagy amikor egy nem React-alapú könyvtárat kell egy React applikációba integrálni. Ezekben az esetekben érdekes lehet a [kontrollálatlan komponensek](/docs/uncontrolled-components.html) használata, az űrlap bementek egy alternatív implementációs módszere.
295295

296-
## Fully-Fledged Solutions {#fully-fledged-solutions}
296+
## Teljes értékű megoldás {#fully-fledged-solutions}
297297

298-
If you're looking for a complete solution including validation, keeping track of the visited fields, and handling form submission, [Formik](https://jaredpalmer.com/formik) is one of the popular choices. However, it is built on the same principles of controlled components and managing state — so don't neglect to learn them.
298+
Ha egy meglévő teljes értékű megoldást keresel, amiben már benne van a validáció, a meglátogatott mezők nyomon követése és az űrlap beküldésének kezelése, a [Formik](https://jaredpalmer.com/formik) az egyik legnépszerűbb választás. Ugyanakkor ez is hasonló alapelvekre épül, mint a kontrollált komponensek vagy az állapotmenedzsment - így ne felejtsd el ezeket sem megtanulni.

0 commit comments

Comments
 (0)