No Code Attached Yet
avatar korenevskiy
korenevskiy
10 Jan 2022

Each field must be created using XML or using PHP.
But this text field cannot be created using PHP.
Examples:
1.<field name="user" type="text"/>
2.

$textfield = Joomla\CMS\Form\FormHelper::loadFieldType('text');
$textfield->name = 'user';
$textfield->renderField();

This not working.
instead of this method, you can use another method
$textfield->render($textfield->renderLayout,[]);
It doesn't work either.
These methods call the text field method $textfield->getLayoutData()
Inside this method there is a method call $textfield->getOptions()
And inside this method, data is collected from $textfield->element which has the type SimpleXMLElement.
This functionality should be called in the $textfield->Setup() method.
But it is not called there, but is called when called ->renderField(); and ->render().
Thus, it is not possible to create fields in PHP.
foreach ($this->element->children() as $option)

Of course, this can be solved with crutches and props by creating a separate pseudo element with the SimpleXMLElement type. or by creating a Layout object separately from the text field object. But this is not normal at all. This is NOT observed in other fields. Moreover, the text field is the base class for many other fields. It is necessary to transfer the call $textfield->getOptions() to the method $textfield->Setup()

avatar korenevskiy korenevskiy - open - 10 Jan 2022
avatar joomla-cms-bot joomla-cms-bot - change - 10 Jan 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 10 Jan 2022
avatar korenevskiy korenevskiy - change - 10 Jan 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 10 Jan 2022
avatar korenevskiy korenevskiy - change - 10 Jan 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 10 Jan 2022
avatar korenevskiy korenevskiy - change - 10 Jan 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 10 Jan 2022
avatar richard67 richard67 - change - 16 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-16 20:59:19
Closed_By richard67
avatar richard67 richard67 - close - 16 Jan 2022
avatar richard67
richard67 - comment - 16 Jan 2022

Closing as there is a pull request.

Add a Comment

Login with GitHub to post a comment