? ? Failure

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
17 Mar 2016

Summary of Changes

This PR adds custom fields functionality to the Joomla CMS, based on the code of DPFields. It will be integrated as a horizontal component. This means, loading of fields into JForm and displaying them on the front is controlled trough the Fields system plugin. Field management is done trough the com_fields component and will be integrated similar to com_categories as a new Fields menu item in the articles manager.

Testing Instructions

Please keep in mind that this PR adds two new tables and new entries to the extension table. The following test instruction acts more as a getting started guide. How to get more information can be found at the end of this pr.

Create a custom field
  1. Log in on the back end.
  2. Navigate to Content -> Articles.
  3. Click on the left sidebar on Fields.
  4. Click on the New button on the top.
  5. Define a title and label.
  6. Click the Save & Close button on the top.
Create an article
  1. Log in on the back end.
  2. Navigate to Content -> Articles.
  3. Click on the New button on the top.
  4. Define a title.
  5. Open the Fields tab.
  6. Add some text on the custom field.
  7. Click the Save & Close button on the top.
View it on the front
  1. Log in on the back end.
  2. Create an article menu item in the menu manager and select the new article.
  3. Go to the front site of your Joomla installation.
  4. Open the article.
  5. Check if the custom field is displayed.

A more detailed test instruction article with screenshots can be found on our blog. We scratched here only on the surface of com_fields. If you want to check out what is all possible with this PR should have a look on the full documentation of DPFields. There are many options like layout overrides, inline field rendering in the article description, categories per fields, permissions. What works for DPFields will also work for com_fields.

Things to clear

As this PR is more or less a one to one copy of DPFields the following approaches do need clarification:

  • Is the system plugin approach right? Or should it be integrated as Observer on JTable and JModelForm?
  • com_fields uses a new permission, who can edit the value of a field? Should that be made as a new permission in core too, as at the moment a field can't inherit from the categories or even the global configuration?

[17 March 2016]
The first iteration of that PR extends com_content and com_users with custom fields of com_fields.
[31 March 2016]
Development has moved to the repository https://github.com/joomla-projects/custom-fields, see you there!

avatar laoneo laoneo - open - 17 Mar 2016
avatar laoneo laoneo - change - 17 Mar 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Mar 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 17 Mar 2016
Milestone Added:
avatar brianteeman brianteeman - change - 17 Mar 2016
Milestone Added:
avatar brianteeman brianteeman - change - 17 Mar 2016
Labels Added: ?
avatar wilsonge
wilsonge - comment - 17 Mar 2016

I'm sure there's going to be a lot more pain to come as we work on finalising this. But thank you very very much for this in advance!

avatar brianteeman
brianteeman - comment - 17 Mar 2016

Please check the language style guide available here https://joomla.github.io/user-interface-text/

avatar Bakual
Bakual - comment - 17 Mar 2016

You will have to adjust the doc blocks so it fits the ones we have in other places in core. Eg:

/**
 * @package     Joomla.Administrator
 * @subpackage  com_fields
 *
 * @copyright   Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

The Mustache library needs to go into the libraries/vendor folder and managed using our composer file.
Mustache is licensed as MIT, which imho is compatible with our GPL. So that should be fine.
However I'm not convinced we need an additonal full template engine just for some custom fields. That's something for PLT to decide I guess. If we're gonna use Mustache for some things in future (eg J4) anyway, then it's fine. Otherwise I think it's gonna add a lot of bloat to the system.

The fotorama librariy is also MIT and should be fine, but its CSS and JS should also be there in uncompressed variants.

Another thing that I saw when looking over the files is that you add a class and a layout file for each supported field type. Couldn't that work from the original formfield classes? Maybe by adding some code there instead?
Don't get me wrong, for a 3rd party extension this is perfect, but for a core extension we could maybe do it simpler (we can after all modify the formfields which 3rd party can't).
I'd love to see all code related to a field in one place instead of having it spread all over the installation.

As for system plugin vs observer, I personally prefer the plugin approach.

avatar mbabker
mbabker - comment - 17 Mar 2016

IMO this needs to go into a branch on https://github.com/joomla-projects/joomla-cms and worked on from there. This PR is not in a state where it is ready for community testing or project review.

avatar brianteeman
brianteeman - comment - 17 Mar 2016

+1 with @mbabker as a single PR of 130+ files it is really hard to comment/review/test as it currently is. If there was a separate feature branch with this merged it would be much more practical - which means it is faster and more efficient


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9452.

avatar laoneo
laoneo - comment - 18 Mar 2016

I agree, that it would be more practical to have the field code all in one place. How it is now, it is relatively easy, I can just iterate over the directory and do know that all the fields in there can be used as custom fields. Porting that to the real fields, would mean I have to load all classes and check if they implement a certain interface as not all fields are meant to be used as a custom field.

Would the PR still get the attention that we can bring it into 3.6 if it is moved to the joomla projects repo? I want to avoid the situation that it will get forgotten somewhere in a branch.

avatar chrisdavenport
chrisdavenport - comment - 18 Mar 2016

As release leader for 3.6, I'll make sure it isn't forgotten. :-)

avatar coolman01
coolman01 - comment - 19 Mar 2016

This looks like something very useful.

I applied the patch on my local machine. First thing was that I had to increase the max-execution time from the standard 30 seconds to 240 seconds before the patch was applied.

When I tried to follow the instructions above, all I got was an error message saying that the component wasn't installed. :-(

avatar Bakual
Bakual - comment - 19 Mar 2016

@coolman01 You may have to discover-install it after applying the patch.

avatar Fedik
Fedik - comment - 19 Mar 2016

@coolman01 and push "fix" for database

avatar laoneo
laoneo - comment - 23 Mar 2016

Did it work the installation?

avatar laoneo
laoneo - comment - 23 Mar 2016

Couldn't that work from the original formfield classes? Maybe by adding some code there instead?

@Bakual how would you do the lookup then, because not every formfield is meant to be available as custom field? Loading all classes in that folder and checking them if they implement a certain interface?

avatar Bakual
Bakual - comment - 23 Mar 2016

@Bakual how would you do the lookup then, because not every formfield is meant to be available as custom field? Loading all classes in that folder and checking them if they implement a certain interface?

@laoneo That would be my first thought, yes. But depends on the ratio of available and supported field classes. Maybe instead of iterating over a folder we could also use a plugin even which returns the available fields (and class location). That way it could also be extended with custom fields.
Just writing from top of my head.

avatar laoneo
laoneo - comment - 24 Mar 2016

Had a discussion yesterday with @dgt41. We both think the interface approach would be enough as looping trough the list is only done when a field is edited in the back end. The the fieldpath of the form can be taken into account as well when more fields should be loaded by a 3rd party component as this is possible already with DPFields now.

avatar Fedik
Fedik - comment - 26 Mar 2016

my 5 cent

Loading all classes in that folder and checking them if they implement a certain interface?

I think it is a road to nowhere :smile:

I more like @Bakual idea to use a plugin event, but instead of return of "known fields" I would like to see something for "register field", like

FormHelper::registerField($name, array(
  'formPatch' => blabla, 
  'classPatch' => blabla, 
  etc ...
))

That can be used during that plugin event.

avatar laoneo
laoneo - comment - 29 Mar 2016

@Fedik feel free to create a PR against my repo that we can have a look how it would go then. For me the overhead of it is not worth the effort.

avatar brianteeman
brianteeman - comment - 29 Mar 2016

It really would be so much easier if this was a branch here

avatar laoneo
laoneo - comment - 29 Mar 2016

Why would it be easier here? I'm waiting for the permission to create a branch on the repo @mbabker suggested that we can move there.

avatar brianteeman
brianteeman - comment - 29 Mar 2016

Thats the branch i was referring to

avatar mbabker
mbabker - comment - 29 Mar 2016

Don't you have permissions to https://github.com/joomla-projects/custom-fields ? (I assume that's why someone created a whole new repo instead of branching permissions on the CMS repo, don't ask me why...)

avatar brianteeman brianteeman - change - 30 Mar 2016
Category Feature Request Fields
avatar laoneo
laoneo - comment - 31 Mar 2016

As requested, development of the custom fields feature has moved to the repository https://github.com/joomla-projects/custom-fields. Please create there the issues and pull requests to improve com_fields. This PR will be closed and a new one will be opened when it is ready for community testing.

Thanks so far for feedback!

avatar laoneo laoneo - change - 31 Mar 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-03-31 12:34:56
Closed_By laoneo
avatar laoneo laoneo - close - 31 Mar 2016
avatar laoneo laoneo - close - 31 Mar 2016
avatar laoneo laoneo - close - 31 Mar 2016
avatar zero-24
zero-24 - comment - 9 May 2016

@brianteeman @wilsonge can you please remove the milestone as it is not merged into 3.6?

avatar brianteeman brianteeman - change - 9 May 2016
Milestone Added:
avatar brianteeman brianteeman - change - 9 May 2016
Milestone Removed:
avatar wilsonge wilsonge - change - 9 May 2016
Milestone Removed:
avatar laoneo laoneo - change - 1 Jul 2016
Title
Custom fields
[OLD] DPFields import as custom fields

Add a Comment

Login with GitHub to post a comment