フォームに任意の数のフィールドを加える
FormFunctionのフォームにいくつのフィールドが必要になるのかわからない場合がある.RepeatingElementを使うと,いくつかの行を含むことのできるスーパーフィールドが作成できる.
In[1]:=
![Click for copyable input](assets.ja/add-an-arbitrary-number-of-fields-to-a-form/In_9.png)
CloudDeploy[
FormFunction[
"addresses" -> RepeatingElement["StreetAddress", {2, 5}],
GeoGraphics[
Append[GeoMarker /@ #addresses,
Style[Line[TravelDirections[#addresses]], Thick, Red]]] &,
AppearanceRules -> <|
"Title" -> "Get travel directions for your trip"|>]]
このフォームは2つのフィールドから始まるが,プラス符号を押すとフィールドを増やすことができる.
![](assets.ja/index.ja/GB_12.png)
![](assets.ja/index.ja/GB_13.png)
フォームを送信して,旅程の地図を見る.
![](assets.ja/index.ja/GB_14.png)