I'm trying to figure out how to prefill subform repeatable fields - the situation is:
/com_manufacturing/admin/views/document/tmpl/edit.php
//some code
<?php
// $subform = JForm::getInstance('row','row');
// echo var_dump($subform);
$xml = new SimpleXMLElement(
'<fieldset
name="rows"
label="COM_MANUFACTURING_ROW_DETAILS">
<field
name="rows-multiple"
type="subform"
label="Subform Field"
description="Subform Field Description"
multiple="true"
layout="joomla.form.field.subform.repeatable-table"
min="1"
max="10">
<form name="rows-multiple-form">
<field
name="id"
type="hidden"/>
<field
name="full_id"
type="sql"
label="COM_MANUFACTURING_ROW_FULL_ID_LABEL"
query="SELECT full_id FROM #__manufacturing_web_import"
key_field="id"
value_field="full_id"
required="true"
/>
<field
name="qta_inviata_for"
type="text"
label="COM_MANUFACTURING_ROW_QTA_INVIATA_FOR_LABEL"
description="COM_MANUFACTURING_ROW_QTA_INVIATA_FOR_DESC"
size="40"
class="inputbox"
default=""/>
<field
name="qta_reso_for"
type="text"
label="COM_MANUFACTURING_ROW_QTA_RESO_FOR_LABEL"
description="COM_MANUFACTURING_ROW_QTA_RESO_FOR_DESC"
size="40"
class="inputbox"
default=""/>
</form>
</field>
</fieldset>');
$this->form->setField($xml, 'params', true, 'params');
$prefillData = array(
"docHead" => array(
"doc_num" => "1401",
"doc_serie" => "1"),
"rows-multiple" =>
array(
"full_id" => "1984",
"qta_inviata_for" => "1001",
"qta_reso_for" => "199"),
array(
"full_id" => "1897",
"qta_inviata_for" => "4000",
"qta_reso_for" => "300"),
);
$this->form->bind($prefillData);
?>
<?php
echo $this->form->renderFieldset('details');
?>
</div>
//some code
in the main form - com_manufacturing/admin/models/forms/document.xml
<?xml version="1.0" encoding="utf-8"?>
<form addrulepath="/administrator/components/com_manufacturing/models/rules">
<fieldset
name="details"
label="COM_MANUFACTURING_DOCUMENT_DETAILS">
<fields
name="docHead">
<field
name="id"
type="hidden"/>
<field
name="created"
type="calendar"
label="JGLOBAL_FIELD_CREATED_LABEL"
description="COM_CONTENT_FIELD_CREATED_DESC"
class="readonly"
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="none"
/>
<field name="created_by"
type="user"
label="COM_MANUFACTURING_DOCUMENT_CREATED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="doc_num"
type="text"
class="inputbox"
default=""
label="COM_MANUFACTURING_DOCUMENT_DOC_NUM_LABEL"
description="COM_MANUFACTURING_DOCUMENT_DOC_NUM_DESC"
required="true"
/>
<field
name="doc_serie"
type="sql"
label="COM_MANUFACTURING_DOCUMENT_DOC_SERIE_LABEL"
query="SELECT id, concat( series_cod, ' (', series_descr, ')') AS title FROM #__manufacturing_web_series"
key_field="id"
value_field="title"
required="true"
/>
<field
name="dt_imported"
type="calendar"
label="COM_MANUFACTURING_DOCUMENT_DT_IMPORTED_LABEL"
description="COM_MANUFACTURING_DOCUMENT_DT_IMPORTED_DESC"
class="readonly"
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="none"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_CONTENT_FIELD_MODIFIED_DESC"
class="readonly"
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="none"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="cod_for"
type="text"
label="COM_MANUFACTURING_DOCUMENT_COD_FOR_LABEL"
description="COM_MANUFACTURING_DOCUMENT_COD_FOR_DESC"
size="40"
validate="codFor"
required="true"
class="inputbox validate-codFor"
default=""
/>
</fields>
<fields name="docBody">
</fields>
</fieldset>
<fields name="params">
<fieldset
name="params"
label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS"
>
<field
name="show_category"
type="list"
label="COM_MANUFACTURING_DOCUMENT_FIELD_SHOW_CATEGORY_LABEL"
description="COM_MANUFACTURING_DOCUMENT_FIELD_SHOW_CATEGORY_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
</fields>
<fieldset
name="accesscontrol"
label="COM_MANUFACTURING_FIELDSET_RULES"
>
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="rules"
type="rules"
label="COM_MANUFACTURING_FIELD_RULES_LABEL"
filter="rules"
validate="rules"
class="inputbox"
component="com_manufacturing"
section="document"
/>
</fieldset>
</form>
Now - I try many many versions of my $prefillData, with the intention to build an associative array that has the same structure that have my form and subform - but no way.
The Joomla Docs deal with this type of prefill situation. Advance Basic
Can someone help me?