Skip to content

Conversation

vojtech-dobes
Copy link
Contributor

There is currently no mention of toggle() in Forms documentation, but the page is quite long, so I rather wrote Planette article. I can try to translate at some point, but if anybody is willing, you are welcome :). Also it would be great if someone reviews the content if there is no toggle-related feature or best-practice missing.

  • is this best practice?
  • EN translation
  • all features documented


Metoda `addCondition()` umí přijímat stejné argumenty jako základní validační metoda `addRule()`, kromě toho, že nepodporuje žádnou chybovou hlášku. V ukázkovém kódu výše tedy volání doslova znamená "pokud je tento prvek zaškrtnutý". Metoda `toggle()` může vždy následovat až po volání `addCondition()`.

Naše ukázka je však zatím nekompletní, metoda `toggle()` totiž vyžaduje argument též: měla by jím být hodnota `id` atributu ve výsledném HTML kódu - element s tímto IDčkem pak bude dynamicky odhalen/skryt právě v závislosti na podmínce definované v `addCondition()`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"též:" is typo probably?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, but it sounds better and less cluttered without it, good idea :).

@milo
Copy link
Member

milo commented Feb 19, 2014

Perfectly readable!
What about blog post instead of planette? :)

@fprochazka
Copy link
Contributor

@milo Imho would be better to write to blog about new articles (in past month, week, ..) but this itself is not a topic on blog.

@vojtech-dobes
Copy link
Contributor Author

@milo I have no problem with that, but translation is one thing to do, and I will also take a look if it has really blog-post feel :). Or do you think it's currently fine as blog post?

Yeah, as @fprochazka says, this is primarily documentation, even though it can also be understood as feature presentation.

.[note]
Proč jsme nemohli všem prvkům nastavit stejnou option `id` a zjednodušit si tak volání `toggle`? V HTML správně nesmí být více prvků se stejným ID. JavaScript by se pak s takovou situací špatně vyrovnával.

Na závěr je ještě vhodné zmínit, že metoda `toggle()` má druhý nepovinný parametr, kterým lze obrátit její chování. Pokud bychom zavolali `->toggle('address-city', FALSE)`, políčko pro zadání města by se naopak zobrazilo pouze tehdy, pokud by checkbox zaškrtnutý nebyl.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tohle jde imho udělat i přes negaci podmínky - např. addConditionOn(..., ~$form::FILLED), ne? Možná bych to zmínil.
(BTW komentovat český text anglicky je, no, trochu weird. :) )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je to pravda, ale mám dojem, že zrovna tohle je skryto pod "stejné api jako addRule()". Raději bych článek udržel "simplier" :).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negace bych spíš vůbec nezmiňoval, jsou dosti neintuitivní a výhledově bych se jich spíš zbavil.

@milo
Copy link
Member

milo commented Feb 19, 2014

@fprochazka @vojtech-dobes OK

@dg
Copy link
Member

dg commented Feb 19, 2014

Super! A co ještě přidat poznámku, že chování lze upravit připisem JS metody Nette.toggle()?

@vojtech-dobes
Copy link
Contributor Author

@dg Dobrý nápad, přidáno.

@vojtech-dobes
Copy link
Contributor Author

I will merge this PR this evening if there are no further comments.

vojtech-dobes added a commit that referenced this pull request Mar 1, 2014
Planette/Forms: added article about ->toggle()
@vojtech-dobes vojtech-dobes merged commit 3a739d3 into nette:nette.org Mar 1, 2014
@vojtech-dobes vojtech-dobes deleted the forms-toggle branch March 1, 2014 19:09
@Majkl578
Copy link
Contributor

Majkl578 commented Mar 1, 2014

Again merged PR which is only in czech. Why do we have guidelines when even we can't follow these rules.

@vojtech-dobes
Copy link
Contributor Author

I apologize for that, but where are the guidelines mentioning this? It might be good thing to add CONTRIBUTING.md file to the repo, because actually I added the EN translation task in description of this PR entirely from my free will, not because any guidelines.

@JanTvrdik
Copy link
Contributor

@Majkl578, @vojtech-dobes Please note that the guidelines (which we do not really have yet) do not apply to planette. They are meant for to the official documentation. There is no point in forbidding community to write articles in language of their choice. What we can do is to encourage people to prefer English if possible.

@vojtech-dobes The Czech version is amazing but an English version would be even better!

@Majkl578
Copy link
Contributor

Majkl578 commented Mar 1, 2014

@JanTvrdik: The sad thing is some ignore it for documentation as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants