-
-
Notifications
You must be signed in to change notification settings - Fork 281
Planette/Forms: added article about ->toggle() #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
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()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"též:" is typo probably?
There was a problem hiding this comment.
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 :).
Perfectly readable! |
@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. |
@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. |
There was a problem hiding this comment.
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. :) )
There was a problem hiding this comment.
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" :).
There was a problem hiding this comment.
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.
Super! A co ještě přidat poznámku, že chování lze upravit připisem JS metody |
@dg Dobrý nápad, přidáno. |
I will merge this PR this evening if there are no further comments. |
Planette/Forms: added article about ->toggle()
Again merged PR which is only in czech. Why do we have guidelines when even we can't follow these rules. |
I apologize for that, but where are the guidelines mentioning this? It might be good thing to add |
@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! |
@JanTvrdik: The sad thing is some ignore it for documentation as well. |
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.