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.

@roland-d roland-d added this to the Joomla 3.9.0 milestone Apr 26, 2018
@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-3.9-dev labels Apr 26, 2018
@brianteeman
Copy link
Contributor

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

@brianteeman
Copy link
Contributor

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 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

@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 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
Contributor

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

@brianteeman
Copy link
Contributor

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

@laoneo
Copy link
Member

laoneo commented Apr 26, 2018

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

@roland-d
Copy link
Contributor Author

@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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@brianteeman
Copy link
Contributor

@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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not utilized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor Author

@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"
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@laoneo
Copy link
Member

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

@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

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
Contributor

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is the same as below. Intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalize F in fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about Field Name or just Name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to Name

name="fieldtype"
type="list"
label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_TYPE_LABEL"
description="PLG_FIELDS__REPEATABLE_PARAMS_FIELDNAME_TYPE_DESC"
Copy link
Contributor

@Quy Quy May 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the extra underscore in PLG_FIELDS__REPEATABLE.

Are icon and multiple attributes necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, removed them.

type="text"
label="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_LABEL"
description="PLG_FIELDS_REPEATABLE_PARAMS_FIELDNAME_NAME_DESC"
icon="list"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are icon and multiple attributes necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, removed them.

Removed obsolete form field settings
@ghost
Copy link

ghost 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.

@ghost
Copy link

ghost 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 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 commented May 19, 2018

Why is only one Test count as successful?

@Quy
Copy link
Contributor

Quy commented May 19, 2018

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

@roland-d
Copy link
Contributor Author

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 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 This Pull Request is Ready To Commit label May 19, 2018
mbabker pushed 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 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 This Pull Request is Ready To Commit label May 19, 2018
@laoneo
Copy link
Member

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 feature/custom-list-input-field branch June 3, 2018 19:16
@coolcat-creations
Copy link
Contributor

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

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

@coolcat-creations
Copy link
Contributor

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

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 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.
Labels
Feature Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet