Repeatable Fields
#61
Posted 25 February 2012 - 07:55 AM
The only bug so far is the one christoph has already mentioned: the visibility settings don't work. Will we have separate options for the repeater and the items inside the repeater?
#62
Posted 25 February 2012 - 08:32 AM
@somartist | modules created | support me, flattr my work flattr.com
#64
Posted 27 February 2012 - 08:23 AM
The only thing I feel is missin is the ability to display repeatable fields as a table, or more of a grid view. What I mean is the field titles are repeated with every repeater row, whereas for invoicing or similar needs it would be great to have them as a grid.
One of the problems here is that as far as I can tell grid views aren't part of jQueryUI (yet), however when I looked at the example 3rd party plugins I immediately got excited by SlickGrid's examples - check out the Making it editable example, as well as looking at the different ways to display data (although data display should be more about the end-user experience and doesn't belong in the admin, but you get where I'm going with the editable part of it at least).
My thinking is that to achieve something like this requires:
- Settling on a jQuery plugin to use - requires some thought as you wouldn't want to have to change it at a later date ideally
- Adding a checkbox to repeatable field configuration to choose to display it as a grid instead of the normal repeater - this needs the usual "only tick this if your repeater will display tabular data" disclaimer as it will obviously break if you add image fields or RTE text fields etc to your repeater.
- Some code to display it as a grid
- Some code to add a button to the end of the table to add another row, as well as a button at the end of each row to remove only that row
#65
Posted 27 February 2012 - 08:37 AM
@somartist | modules created | support me, flattr my work flattr.com
#66
Posted 27 February 2012 - 09:16 AM
My thinking was that when they're in the database they're essentially the same thing, so rather than reinvent the wheel...
You still want the fields values to be stored separately in the database - for example if you then built a template to display rows from an invoice it would need to calculate the totals for each row (quantity x unit price) and the overall subtotal, tax and total. Similarly you could then build a module to automatically email something like that to a client when the page is published.
The way I'm thinking about it, a "row" is a repeatable element, which is where I thought it would be a natural extension of the current module (whether as part of this module or another additional module that requires the current module).
#67
Posted 27 February 2012 - 09:30 AM
But maybe I'm wrong. As I see it is that you have a table with text and number, not images, page refs , RT's etc. So I could see an easy implementation that's using datatables and the data stored as serialized array. Just trying to look at it different.
@somartist | modules created | support me, flattr my work flattr.com
#68
Posted 27 February 2012 - 10:09 AM
#69
Posted 27 February 2012 - 12:16 PM
- You can sort of use repeatable fields for this now, but they won't look like a spreadsheet
- Repeatable fields aren't ideal for this because they can support ANY fieldtype. In a grid/spreadsheet view, you only need to support limited data types.
- I think it would work best as it's own FieldtypeMulti, where it manages it's own data with columns in a table⦠more traditional database style. PW API supports searches in anything that has it's own column in the DB schema, so long as an index is defined for it (in MySQL). This would be more efficient in this case because the limited set of data types you'd need to support line up nicely with how you'd define a DB table. Pages are of course a lot more flexible, but you don't need that flexibility here.
- I've built fieldtypes like this for managing property availability and rates. It's not hard to do by making your own FieldtypeMulti. This is exactly what the FieldtypeMulti class is designed to do. (FieldtypeComments and others are based on it). The main challenge in this Grid Fieldtype would be in making the schema configurable per field, but I still think it's well within reach.
The only bug so far is the one christoph has already mentioned: the visibility settings don't work. Will we have separate options for the repeater and the items inside the repeater?
Sorry, I missed that before. I fixed and committed it over the weekend.
2) Is there a special setting to make the output of a repeatable field viewable to users who are not logged in? Currently I only see the output when I'm logged in.
Repeater fields are meant to be iterated like any other group of pages, and they are technically no different. That means you have to foreach() them and output them in the manner you want. I will probably include some default render() method in there in a future version, but it would mainly only be useful for testing/debugging. There is also an example of how to output repeater fields on the first page of this thread.
Field contexts on a template level will allow so much flexibility in the admin. We can then create ever more usable, custom admin screens for clients - simplifying the editing process for them.
I'm glad to report that Template>Field contexts are now completed and working. I'm going to be testing here more before committing to the core source, but wanted to let you guys know you'll be able to use them in the next week. I'll be posting a video in the next day or two. Also, I have limited the field properties that can be configured per-template to include just these:
- Label (including all languages)
- Description (including all languages)
- columnWidth
- Visibility (collapsed settings)
#70
Posted 27 February 2012 - 03:26 PM
Sorry Soma if you had suggested that or that was what you meant - it wasn't until ryan said FieldType multi that it sank in
#71
Posted 27 February 2012 - 04:19 PM
Repeater fields are meant to be iterated like any other group of pages, and they are technically no different. That means you have to foreach() them and output them in the manner you want. I will probably include some default render() method in there in a future version, but it would mainly only be useful for testing/debugging. There is also an example of how to output repeater fields on the first page of this thread.
Thanks for your reply, Ryan.
The problem I have is a little different. I have no problem creating output with a foreach(), the problem is that I only see that rendered HTML output if I'm currently logged into the system. So if I log out or view the page with a different browser I see nothing rendered.
Oh, and while I wanted to check the page just now in the back end I got an error:
Duplicate entry 'for-page-5799-5807' for key 2
#72
Posted 27 February 2012 - 04:50 PM
#74
Posted 27 February 2012 - 07:54 PM
#75
Posted 28 February 2012 - 02:37 AM
I can't imagine you're not able to reproduce this. I got simple repeater and the following code won't show anything when I'm logged out.
foreach($page->items as $p) {
echo "<p>$p->item_title</p>";
}
@somartist | modules created | support me, flattr my work flattr.com
#77
Posted 28 February 2012 - 09:37 AM
@somartist | modules created | support me, flattr my work flattr.com
#79
Posted 29 February 2012 - 12:38 PM
hm... how do I attach an image here??
...i will just link to it:
EDIT: Now I see the attach files option on the reply full editor... I swear it wasn't there when I wanted to attach the above image!
#80
Posted 29 February 2012 - 01:21 PM
This link results in a 403 error. Maybe that's why the image couldn't be embedded?...i will just link to it: https://lh4.googleus...JdizWZlDsybcyIw
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













