Skip to content
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

[FEATURE] A Repeatable Custom Field #20243

Closed

Conversation

@roland-d
Copy link
Contributor

@roland-d roland-d commented Apr 26, 2018

Summary of Changes

This pull request adds a new custom field to the core of Joomla. This custom field is called Repeatable because it allows users to enter a repeatable list of items which in turn are by default shown as a list. With a template override you can do a whole lot of other things with this.

Testing Instructions

Installation

  1. Copy all the files to their respective location in your site
  2. Go to Extensions -> Manage -> Discover
  3. In the list find Fields - Repeatable
    image
  4. Select this plugin
  5. Click on Install
  6. Go to Extensions -> Plugins
  7. Filter the list on repeat
  8. Select this plugin
    image
  9. Click Enable

Usage

  1. Go to Content -> Fields
  2. Click New
  3. Give the Custom Field a Title of Marbles
  4. As Type select Repeatable (repeatable)
  5. At the bottom click on the green + to add a new field
    image
  6. Enter the name of the field Size
  7. Select a type of field Text
  8. Click again on the green +
  9. Enter the name of the field Description
  10. Select a type of field Text Area
  11. Save the custom field and it looks like this:
    image
  12. Close the custom field
  13. Click on Articles
  14. Click on New
  15. Give the Article a Title of All about marbles
  16. Click on the Fields tab
  17. Click on the green + sign to add a new line
  18. Enter the text Small
  19. Enter the description I want to make this marble grow
  20. Click on the green + sign to add a new line
  21. Enter the text Medium
  22. Enter the description I have been growing this for a while
  23. Click on the green + sign to add a new line
  24. Enter the text Large
  25. Enter the description It is as big as it gets
  26. Your table now looks like this:
    image
  27. Save and close the article
  28. Now view the article on the site
  29. Your article should look like this:
    image

There you have a it. Users can now create their own lists. If you are creative, you can use it to make tables or other kinds of lists.

Feedback

Let me know if this is something to be considered for core. If not, I will just close this request.

@brianteeman
Copy link
Member

@brianteeman brianteeman commented Apr 26, 2018

What are the advantages/differences over this field and the existing list field?

@brianteeman
Copy link
Member

@brianteeman brianteeman commented Apr 26, 2018

As its a new core plugin it needs to be added to the list in libraries/src/Extension/ExtensionHelper.php

@Septdir
Copy link
Contributor

@Septdir Septdir commented Apr 26, 2018

@roland-d Why do not you want to make a separate plugin and add it to JED ?

The field looks quite useful and will probably be in demand

Why do you need to add it to the core ?

@roland-d
Copy link
Contributor Author

@roland-d roland-d commented Apr 26, 2018

@brianteeman The distinct difference between these two is that with list you need to create the list when you create the custom field and is shown as select list to the end user. Displaylist allows the end user to create a list rather than make a selection. I hope that explains it.

@Septdir I don't want to maintain an extension on the JED. The field seems useful enough for the community, so I figured I share it.

@laoneo
Copy link
Member

@laoneo laoneo commented Apr 26, 2018

As we do have a list already, I would rather see a new function in core to define a default layout for the field and provide different layouts for the same field type. For the list it would mean to add a new file here like /plugins/fields/list/tmpl/list_ul.php and then provide these layouts as option in the field. What do you guys think?

@brianteeman
Copy link
Member

@brianteeman brianteeman commented Apr 26, 2018

thanks @roland-d makes sense now - which it should have done because the name is perfect - sorry

@brianteeman
Copy link
Member

@brianteeman brianteeman commented Apr 26, 2018

@laoneo something like
display as select/ul/ol/ etc?

@laoneo
Copy link
Member

@laoneo laoneo commented Apr 26, 2018

Or like what we have as layouts in modules and views.

@roland-d
Copy link
Contributor Author

@roland-d roland-d commented Apr 26, 2018

@laoneo I thought of adding options to select which layout it would have but for new decided against it because the output is generally styled via a template anyway. So I figured, why add even more options.

type="text"
icon="list"
label="PLG_FIELDS_DISPLAYLIST_PARAMS_LIST_NAME_LABEL"
description="PLG_FIELDS_DISPLAYLIST_PARAMS_LIST_NAME_DESC"

This comment has been minimized.

@Quy

Quy Apr 26, 2018
Contributor

Reduce by 1 indent.
Sort in this order: name, type, label and description

This comment has been minimized.

@roland-d

roland-d Apr 26, 2018
Author Contributor

Done

@brianteeman
Copy link
Member

@brianteeman brianteeman commented Apr 26, 2018

@laoneo I thought of adding options to select which layout it would have but for new decided against it because the output is generally styled via a template anyway. So I figured, why add even more options.

@roland-d I think he meant not to add this new field but to add this as a layout to the current select list field

; Note : All ini files need to be saved as UTF-8

PLG_FIELDS_DISPLAYLIST="Fields - Display List"
PLG_FIELDS_DISPLAYLIST_LABEL="Display List (%s)"

This comment has been minimized.

@Quy

Quy Apr 26, 2018
Contributor

Not utilized.

This comment has been minimized.

@roland-d

roland-d Apr 26, 2018
Author Contributor

@Quy Yes this is utilized. This string is used in the list where you select the field when creating a new custom field.

roland-d added 2 commits Apr 26, 2018
@roland-d
Copy link
Contributor Author

@roland-d roland-d commented Apr 26, 2018

@brianteeman Ok, if that is what he meant than that would be a feature based on the existing list field and serves a different purpose.

description="PLG_FIELDS_DISPLAYLIST_PARAMS_LIST_NAME_DESC"
icon="list"
multiple="true"
>

This comment has been minimized.

@Quy

Quy Apr 26, 2018
Contributor

Change this to /> and delete </field>.

@laoneo
Copy link
Member

@laoneo laoneo commented Apr 26, 2018

Whats the difference of this plugin to the list field? Only the layout or not? The rest is more or less the same.

@roland-d
Copy link
Contributor Author

@roland-d roland-d commented Apr 26, 2018

@laoneo Apparently my two tries so far have failed to make clear what this plugin does different so going to give it another try. It is not the layout, otherwise I would have added that as an option to the list.

Here is an image to show you the difference:
image

The existing List is a dropdown, the new Display List allows the one consuming the article to enter a list by themselves rather than having to choose from a fixed list. This can be a usergroup that has no access to maintain the custom fields but has access to create articles. To me this is a distinct difference between these two fields.

@AndyGaskell
Copy link
Contributor

@AndyGaskell AndyGaskell commented Apr 26, 2018

I think this would be nice, and a feature that a lot of folk would find useful.
I do agree with @laoneo though, there is quite a big overlap with the current list item.

Perhaps an addition to the existing list plugin, with an option of choosing tmpl output. So, perhaps to go with the list.php we could add a ul.php and a li.php, and a way of choosing the display when editing the list, as per template overrides.

@brianteeman
Copy link
Member

@brianteeman brianteeman commented Apr 26, 2018

@roland-d i get it

// Setting the value for the field and the item
$model->setFieldValue($field->id, $item->get('id'), $value);
}
// Setting the value for the field and the item

This comment has been minimized.

@Quy

Quy May 19, 2018
Contributor

The comment is the same as below. Intentional?

This comment has been minimized.

@roland-d

roland-d May 19, 2018
Author Contributor

@Quy Wasn't intentional, cleaned up the code a bit and pushed it

PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_TEXT="Text"
PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_TEXTAREA="Text Area"
PLG_FIELDS_REPEATABLE_PARAMS_FIELDS_DESC="Add one or more form fields"
PLG_FIELDS_REPEATABLE_PARAMS_FIELDS_LABEL="Form fields"

This comment has been minimized.

@Quy

Quy May 19, 2018
Contributor

Capitalize F in fields.

This comment has been minimized.

@roland-d

roland-d May 19, 2018
Author Contributor

Done

PLG_FIELDS_REPEATABLE="Fields - Repeatable"
PLG_FIELDS_REPEATABLE_LABEL="Repeatable (%s)"
PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_DESC="The name of the field to display in the form"
PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_LABEL="Fieldname"

This comment has been minimized.

@Quy

Quy May 19, 2018
Contributor

How about Field Name or just Name?

This comment has been minimized.

@roland-d

roland-d May 19, 2018
Author Contributor

Renamed it to Name

name="fieldtype"
type="list"
label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_LABEL"
description="PLG_FIELDS__REPEATABLE_PARAMS_FIELDNAME_TYPE_DESC"

This comment has been minimized.

@Quy

Quy May 19, 2018
Contributor

Remove the extra underscore in PLG_FIELDS__REPEATABLE.

Are icon and multiple attributes necessary here?

This comment has been minimized.

@roland-d

roland-d May 19, 2018
Author Contributor

Not needed, removed them.

type="text"
label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_LABEL"
description="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_DESC"
icon="list"

This comment has been minimized.

@Quy

Quy May 19, 2018
Contributor

Are icon and multiple attributes necessary here?

This comment has been minimized.

@roland-d

roland-d May 19, 2018
Author Contributor

Not needed, removed them.

Removed obsolete form field settings
@joomlara
Copy link

@joomlara joomlara commented May 19, 2018

I have tested this item successfully on f6542e0


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

@joomlara
Copy link

@joomlara joomlara commented May 19, 2018

Works as expected. Nice feature!
And unlike Yves, I really liked your clear testing instructions Roland....
marbles

@ot2sen
Copy link
Contributor

@ot2sen ot2sen commented May 19, 2018

I have tested this item successfully on e13a749

Still works


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

@ghost
Copy link

@ghost ghost commented May 19, 2018

Why is only one Test count as successful?

@Quy
Copy link
Contributor

@Quy Quy commented May 19, 2018

Because joomlara tested the commit (f6542e0) before the last commit (e13a749).

@roland-d
Copy link
Contributor Author

@roland-d roland-d commented May 19, 2018

With the number of tests this PR has gotten and the last commit being trivial one could say it has had enough tests ;)

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 3.10.0 milestone May 19, 2018
@Quy
Copy link
Contributor

@Quy Quy commented May 19, 2018

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC label May 19, 2018
mbabker added a commit that referenced this pull request May 19, 2018
@mbabker mbabker added this to the Joomla 3.9.0 milestone May 19, 2018
@mbabker
Copy link
Contributor

@mbabker mbabker commented May 19, 2018

Merged to 3.9 via 327fa65

@mbabker mbabker closed this May 19, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC label May 19, 2018
@laoneo
Copy link
Member

@laoneo laoneo commented Jun 2, 2018

For the people who are requesting a layout chooser per field, It got merged today by #18571.

@roland-d roland-d deleted the roland-d:feature/custom-list-input-field branch Jun 3, 2018
@coolcat-creations
Copy link
Contributor

@coolcat-creations coolcat-creations commented Jun 26, 2018

Hi there! Is there a way to fix the appereance of the Media field? Is it related to the repeatable field or a separate issue?
grafik

@roland-d
Copy link
Contributor Author

@roland-d roland-d commented Jun 26, 2018

Hello, this is a separate issue. The styling just doesn't fit.

@coolcat-creations
Copy link
Contributor

@coolcat-creations coolcat-creations commented Jun 26, 2018

Sorry for the late testing... But if you use 2 editor fields with JCE you can't type in into the second editor field. I know it's not core related (With TinyMCE everything works fine) but maybe something that can be still fixed?

@coolcat-creations
Copy link
Contributor

@coolcat-creations coolcat-creations commented Jun 26, 2018

Created the issue and will post the JCE one also towards JCE ;)

@joomla joomla locked as resolved and limited conversation to collaborators Jun 26, 2018
@laoneo
Copy link
Member

@laoneo laoneo commented Jun 26, 2018

I'm going to lock this one. If there are followup issues, please open a new issue or pull request. Thanks for understanding.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

You can’t perform that action at this time.