-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[com_fields] Remove alias from fields #13182
Conversation
Yes indeed it is simpler, but there are several advantages when using aliases Most notable are:
|
The alias is only used in the form, not when the field is displayed in a regular view. So it would only be useful for customising the edit views. |
right, i see so either it should be used more or be removed as this PR does |
I don't see the benefit really. The name of the field in the outputed HTML is now jform_2, which is hard for the site admin to imagine. I like the change to move the fields away from the params fields. I would put that into a separate PR to not mix stuff and keep this one smaller. |
Main benefit is to remove a field that isn't needed at all. And to remove confusion as to what an "alias" does for fields. Because an alias is used for URL routing in all other forms, which makes no sense at all when it comes to fields (we don't have URLs for fields). So its named alias but does something completely different.
It is
The move away from the params was a requirement for removing the alias. I saw that during writing the PR. That is the sole reason it is in this PR and not separate. We can split it of course to make reviewing a bit simpler, but it's the same thing to test in the end. |
Some users of DPFields were working with the alias in template overrides, eg. @marcodings https://www.youtube.com/watch?v=fgDoZsD71H8&t=1652s When we rewind the content parser feature joomla-projects/custom-fields#135 . Then it would mean that There was a reason that we introduced it in DPFields, so taking away all the stuff which is technically not obvious on the first sight makes for me no sense. You are right, the naming is wrong, but I would not remove it. |
The thing is, if we now introduce stuff which isn't needed currently, we add technical debt that can't be changed later due to backward compatibility. It is simple to add a field (alias, name, whatever) again later if we ever introduce such a content parser feature. However that content parser would obivously work fine also with the ID of the field (as well as template overrides). Imho we should keep it to the minimum we currently need and support and can be tested, and expand it later if we add the corresponding feature. |
I think for a custom field which represents a JFormField it makes sense to have a form name (alias) attribute. It is in use right now as form name, just has the wrong label. |
So we would have to rename it so it's clear what it does. Because currently it sure isn't clear and confusing. Much more important than the formfield name would imho be the ID of the field when shown in frontend. Currently it shows there with an ID eg "field-entry-2". But if you think about this, this is already highly problematic. The field should have no ID at all. Because as soon as you want to show the fields on a page where multiple items are shown (eg one in a module and in component, or in a list), it will produce duplicate IDs on the page and thus rendering the HTML invalid. That doesn't matter if it's an alias or id that is used here. But that certainly is a different PR to remove that. |
Thomas the definition of what is not used or is used is very subjective. We use (dp-)fields extensively and we use for example overrides and tags to assign fields to content. |
Of course I understand that. If someone can explain me why the need for an alias is there, then I'm fine with that. I'm not sure I understand what you mean with "tags" and "overrides". This PR doesn't touch anything like that. I don't see how that would change the ability to override the field or assign it to content. Keep also in mind that this only changes something for the edit forms (eg article edit). For regular views like a single article page, the fields will behave exactly as before as the alias isn't used at all there. |
20bd4c5
to
ce89009
Compare
I have tested this item ✅ successfully on 18b9509 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13182. |
Using ids as form field names, and when creating custom layouts is a little weird and problematic for portatibilty, imagine i want to copy i custom layout to another web-site i will have to remap the ids about form field name, to give a comparison imagine: article (/record) 'title' was field '1' and I agree 'alias' term here is not proper, just use another term like 'name' |
I agree on @ggppdk' proposal. I would also rename it to name and it will become more clear then. |
I obviously disagree 😄
First: We're only speaking about forms, not where the field is displayed in eg an article view. In that view it already uses the ID and not the alias. The alias is only ever used in a form generated by JForm. Are you really going to customise that one somehow? And why are you needing the id/name then and not take the class? Second: You're exchanging one possible issue with another one. If the user is going to adjust the alias, it would break the custom layout as well. Personally I'd rather do the layout on something I'm sure the user doesn't accidentally change.
Imho it's not the same case as in a record the developer knows for sure how each field is named and the name has to relate to table fields, In our case, they are user generated and it doesn't really matter at all how they are named. Actually using the ID does again map to the database entry and makes the code much simpler. |
A use case to use names in template overrides can be found here https://www.youtube.com/watch?v=fgDoZsD71H8&t=1652s. As I said already quite a bit of DPField users, did use the fields based on their alias, like
They used then that layout among different sites and didn't had to mess with ID's. I understand you, that it technically makes sense to remove the alias. But I think we need to hear here the end user as well. |
Please don't link to the video if you don't give the exact poisition where he explains the use case. I find it very hard to follow Q/A type of records to find the answer you're referring
That code wouldn't work because the alias isn't available in the formfield. They need to use $form->id (eg jform_params_alias) or $form->name (eg jform[params][alias]). |
Sorry tought the t parameter was correct, but it always started from where I left. Here is the correct link https://www.youtube.com/watch?v=fgDoZsD71H8&t=26m5s. |
Ah I see it now, but that is about frontend views, not form. The alias isn't used here for anything at all, it would just serve as a way to distinguish fields in custom overrides, but there are several other properties that can be used to achieve the same. |
18b9509
to
1a7be2d
Compare
Use a CSS class to reference a specific field ? that sounds a little strange Drupal instead of "alias" or "name" calls it "Machine name", and looks like: and i understand why the "Machine", it is because this is not directly visible by site visitors / users
<select name="field_color" ... Then besides using it layouts / custom layouts it is also used to create a field specific class (the "render" class we already have can be used by many fields) So in to total the "alias" or "name" or "field name" or "machine name" is useful as:
About being uniqueness it should be on: |
What is strange here? We do that all the time. Actually we use IDs very rarely in core.
You're aware we're still only talking about forms here. And I honestly doubt a lot of adjustments happen for those forms.
As explained already, it's a bad idea to use the ID in most cases. For forms it may work because we usually don't have multiple instances of the same form open on the same page, but for rendered fields eg in an article it's a very bad idea to use IDs.
Alias has to be unique sidewide. Because even if you don't have the same form open twice, you may have different forms open on the same page (eg a login form in the module and a contact form in component). If both forms allow for custom fields and one field shares the same alias, then you already got a possible problem. |
For reference: #13335 describes one of the current issues with using that alias (and without making sure it's unique). |
We speak of the 'render' class parameter, right ?
No using IDs does not work well, it makes working with forms unfriendly
This is something that should change / can change with little effort, -- It should also be usuable in viewing ('value rendering') layouts -- About CSS class that uses the alias (=field name), About uniqueness, i see, maybe unique site wide, ok, And in places that it is needed, id="jform_custom_color_45" name="jform[custom][color]" where 45 is the id of the field, name=".....", only needs to be unique inside the form, and not in side the page or inside the iframe, Whatever is decided, i explained some points in my above answers, about: |
I have tested this item 🔴 unsuccessfully on a9e3ad3 In "User"
After changing Field-Position in Backend: Position of Values don't move with Fieldname
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13182. |
@franz-wohlkoenig That happens with and without this PR, right? At least I can reproduce it in clean staging as well. So it would be unrelated to this PR and a different issue needs to be opened. |
@Bakual Tested on Article: New "Editor"-Field in Backend, filled with Value, saved. Open in Frontend, add Numbers in Field, saved > Value isn't saved. In Short: Modify and saving works in back-, not in frontend. |
@franz-wohlkoenig |
Testing on Joomla! 3.7.0-alpha2-nightly. |
The fix for the frontend issue has been merged 3 days ago. If your nightly is older, then it explains that behavior. |
@franz-wohlkoenig See #13589 for the misaligned values. |
I have tested this item ✅ successfully on a9e3ad3 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13182. |
@Bakual update nighlty every morning. |
…ams JLayout. Adjusted the JLayout to take a custom tab name.
a9e3ad3
to
eb8664f
Compare
@franz-wohlkoenig You were right, something was wrong there again. I have now rebased the branch with current staging and now it should work again. |
I have tested this item 🔴 unsuccessfully on eb8664f In "Contact"
|
Please always test if the issues found are because of this PR or also in current staging. |
I have tested this item ✅ successfully on eb8664f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13182. |
Can we close this one in favor of #13576? There are some people who do need the alias/name field. So it should not be removed, but the name of the field alias field should be changed instead. |
I still don't understand the need for it and I think it will produce more issues than advantages. |
There are three people just here who say, they need that field. So why then remove something which is needed by some? |
Because they can do the same with IDs, or they didn't understand what this PR is about (this is about forms, not item display). And we otherwise make the code more complex for no gain. |
Closing as there doesn't seem to be much support 😄 Please instead test
|
Currently, com_fields uses an alias field as a name for the field in forms. But that alias really isn't used for anything else and can as well be substituted with the id, making the code actually simpler.
Summary of Changes
Removes the alias from fields and changes its use to use the ID instead.
To avoid conflicts in general, fields are now stored in an own group called "com_fields" instead of the "params" that is used already by most extensions.
Testing Instructions
Test creating, editing, deleting fields both in backend and frontend.
Test for fields in articles, users and contacts.
Documentation Changes Required
None.