I have a form for adding animals with a field called species. This UI Component is:
<field formElement="select" name="species" sortOrder="10">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">Animal</item>
</item>
</argument>
<settings>
<dataType>text</dataType>
<label translate="true">Species</label>
<dataScope>species</dataScope>
<validation>
<rule name="required-entry" xsi:type="boolean">false</rule>
</validation>
</settings>
<formElements>
<select>
<settings>
<options class="Vendor\Module\Model\Config\Source\Species"/>
</settings>
</select>
</formElements>
</field>
Vendor\Module\Model\Config\Source\Species returns an array of animals (e.g. cat, dog, cow, horse).
The issue is that, the client has asked that if the customer has more than 1 animal to show then an extra species field should come for each animal. The developer at the time has coded this on the front end to save the multiple species as a json.
But it gets worse, they've also coded the json to have a second question - 'amount' as well, which shows how many of each animal the customer has.
An example of the json is:
[{"species":"Horse","amount":"4"},{"species":"Cat","amount":"2"}]
How do I modify my UI Component form (Vendor\Module\view\adminhtml\ui_component\animal_form.xml) to show a drop-down when the value is from the source array ('cat', 'dog', etc), and multiple fields (perhaps in a table?) of species and amounts if the response is in json?


