Good morning,
I have a question. I create my own fields in my own component. I'm using the "SimpleXMLElement" class. The form generates via getForm work perfectly:
$newfieldset = new SimpleXMLElement('<fieldset></fieldset>');
$newfieldset->addAttribute('name', 'case_customfields');
foreach($customfields as $customfield)
{
$field = $newfieldset->addChild('field');
$field->addAttribute('name', $customfield->field_name . '-' . $customfield->id);
$field->addAttribute('type', $customfield->field_type);
$field->addAttribute('default', $customfield->field_default_value);
$field->addAttribute('label', $customfield->field_label);
$field->addAttribute('description', $customfield->field_description);
}
$form->setField($newfieldset);
return $form;
I also modified the getItem function, which returns values for my own fields:
$customfields_value = $this->getCustomFieldsValues($pk);
foreach($customfields_value as $customfield_value)
{
$singleCustomField = $this->getSingleCustomFields($customfield_value->custom_fields_id);
$field_id = $singleCustomField['id'];
$field_name = $singleCustomField['field_name'];
$field = $field_name . '-' . $field_id;
$item->$field = $customfield_value->value;
}
return $item;
Work perfectly too.
The problem is that in the edit form I do not see custom values. If I create a static form in XML (models / forms), the data is. For fields created via "SimpleXMLElement" - data is not in the form.
Of course, I can load data into the form via the "SimpleXMLElement" class in getForm, but that seems to me to be a bad way.
Where do I make a mistake? And thank you in advance for help.