Im trying to prefill my subform with datarows from the database.
newcustomerform.xml
<?xml version="1.0" encoding="utf-8"?> <form addfieldprefix="Mydestiny\Component\Mydestiny\Site\Field"> <fieldset> <field name="id" type="text" readonly="true" class="readonly" default="0" description="JGLOBAL_FIELD_ID_DESC"/> <field name="contacts" type="subform" formsource="components/com_mydestiny/forms/contacts.xml" labelclass="control-label" multiple="true" buttons=" " layout="joomla.form.field.subform.repeatable-table" class="uk-table uk-table-middle" /> </fieldset> </form> contacts.xml
<?xml version="1.0" encoding="utf-8"?> <form> <fieldset> <field name="account" type="radio" default="0" label="" description="" class="btn-group btn-group-yesno"> <option value="1">ja</option> <option value="0">Nee</option> </field> </fieldset> </form> I tried this:
$form = Form::getInstance('com_mydestiny.newcustomerform', 'contacts', array('control' => 'jform')); $input = Factory::getApplication()->input; $formValues = $input->getArray(array( 'jform' => array( 'contacts' => 'array' ) )); $prefillData = array("contacts" => array("account" => 1)); $form->bind($prefillData); But that doesn't do anything.
Can anyone help me?