The big problem of the Form and the fields. #38226
korenevskiy
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I will describe the problem of field withdrawal for the Administrative Panel.
We know that programming happens :
-Imperative
-Declarative
Approximate code for these files :
This is declarative programming.
But
After that, the contents of the XML file are loaded into the
Form
object (Joomla\CMS\Form
)But the loading happens as follows. The XML file is loaded into a multidimensional
SimpleXMLElement
arrayThis is where the XML data loading ends.
After that, the Form object goes to the list of fields array.
Then, according to this list of fields, an empty field object is created for each field.
A multidimensional
SimpleXMLElement
array of this field is placed in each field object.Thus , each interface object is a wrapper over a multidimensional
SimpleXMLElement
array .Why these difficulties?
Why is it impossible to serialize an XML file into
FORM
object properties and field object properties?Is this approach object-oriented? Does the multidimensional array
SimpleXMLElement
have anything to do with declarative programming?Work:
In the code I have a field object, I assign a new value to the property of this object.
The object of this field serializes the new value, and then enters it into the global multidimensional array
SimpleXMLElement
.Then, when preparing the data of this field, the object of this field turns into a global multidimensional array
SimpleXMLElement
finds its data, diserializes it back to perform calculations.The object serializes these calculations back and puts them in a global multidimensional array
SimpleXMLElement
When rendering the field layout, data is reverse extracted from the global multidimensional
SimpleXMLElement
array, diserialization occurs, and after that the page with fields is rendered.In the case when we need to transfer a complex object between the field object and the layout. We will need to serialize a complex object into a string and then deserialize it back on the layout side. An object of a date, array, etc., we cannot directly transmit data to the layout.
This is not an object-oriented approach, and it is not a declarative approach.
Why didn't we make it easier, more convenient, more accessible?
If we consider Joomla as a Framework, then the use of Form and Fields objects imposes very large restrictions, in the case when it is necessary to do something a little differently than provided for by these fields. When designing the Joomla interface, the developer must be sure that he will be able to expand the fields and form of the page. Since the developer does not have the right to expand the form and fields, due to very very strong limitations. The developer will not use these objects. Even if these objects become better functionally, they do not give freedom. We can observe the result in components such as JoomShopping and other components.
At the current time, I suggest:
Field
objects access a multidimensionalSimpleXMLElement
array only in one->Setup()
method.Field
object, completely abandon access to a multidimensionalSimpleXMLElement
array.Field
without using anSimpleXMLElement
array. So that the field can be created only by assigning values to the properties of this object.These 3 steps will allow us to gradually move away from the multidimensional Simplexmlelement array in the future.
The current design creates big problems for creating complex fields: Graphs, Tables.
Friends who came up with this structure. Please explain what is the purpose of one multidimensional XML array in each field object?
Beta Was this translation helpful? Give feedback.
All reactions