-
Notifications
You must be signed in to change notification settings - Fork 71
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
Repeated section of length of zero #266
Labels
Comments
Hi Stuart,
I don't understand this part. Can you elaborate? |
Currently, every repeating group must have at least one row. If there is only one row, the “Remove Row” (or “Remove Item”) button is disabled. There are cases where this behavior is desirable: for instance, an ordering system should make sure there is at least one line item in every order. However, there are also many more cases where it is quite legitimate for a group to have zero rows. Consider attaching files. I want the user to be able to attach one or more files to a post. But for each one I should also require them to describe the file’s relation to the post. I need to be able to legitimately post
Attachments = []
Not
Attachments = [
“file” => “”,
“description” => “”
]
And I can NOT mark either “file” or “description” as required, as the validation would fail when the user (with role of “contributor”) actually had no attachments to post. And remember, when writing your answer: The description should NOT be forced to match what it might be in the WP media database. A file can have different relationships to different posts and therefore different “description” values in different posts. Thank you!
Stuart Simon
Graphics Specialist
LSU Human Development Center
411 S Prieur St
New Orleans, LA 70112
http://www.hdc.lsuhsc.edu/
From: Michael Uno [mailto:[email protected]]
Sent: Sunday, February 19, 2017 7:19 PM
To: michaeluno/admin-page-framework <[email protected]>
Cc: Simon, Stuart A. <[email protected]>; Author <[email protected]>
Subject: Re: [michaeluno/admin-page-framework] Repeated section of length of zero (#266)
*EXTERNAL EMAIL: EVALUATE*
Hi Stuart,
What I need is to allow my repeating group to have zero length.
I don't understand this part. Can you elaborate?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#266 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ATRYOHMUDzA3byP8niUNTyw1u6YgvR2dks5reOocgaJpZM4MAG8E>.
|
I thought I should be more succinct.
A repeating group named "group1" has two child fields, "field1" and "field2." When saved to the database, the data represented by the entries in the repeating group will be serialized thus:
$_POST['group1'] = array(
0 => array(
'field1' => 'foo',
'field2' => 'bar'
),
1 => array(
'field1' => 'Lorem'
'field2' => 'ipsum'
) ...
)
In other words, the repeating group is always bound to a non-associative array in the data. What I am asking for is the special case that the repeater is bound to an empty array. The repeater in this case should have zero entries (where an "entry" may be called a "group" or "row" ). In my mind, all that is needed in the repeated group's DIV in that case should be the button that adds an entry.
What I can do is to show you how those of your competitors have handled the special case of a repeating field with zero entries.
…Sent from my iPhone
On Feb 19, 2017, at 7:19 PM, Michael Uno <[email protected]<mailto:[email protected]>> wrote:
*EXTERNAL EMAIL: EVALUATE*
Hi Stuart,
What I need is to allow my repeating group to have zero length.
I don't understand this part. Can you elaborate?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#266 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ATRYOHMUDzA3byP8niUNTyw1u6YgvR2dks5reOocgaJpZM4MAG8E>.
|
Michael:
I can't believe you're as out of touch with Github and your e-mail as you seem to be. When I first posted this issue, I had already contacted you using http://admin-page-framework.michaeluno.jp/contact/order-new-features/ at least two weeks before. Search your inbox for [email protected]<mailto:[email protected]> and click the earliest message that comes up. Maybe it was too much for you to deal with at the time.
When I say zero-length repeater, I mean that I want a repeater with no items/rows. You could also say that it has no children, or that the repeater occurs zero times. I want my contributors to attach one or more files to my posts, and I want to make sure they provide descriptions of each one. Two fields: File and Description, both required. But most of the posts will have no need for attachments, and thus the section should not occur at all for most posts.
Of course I could create a related post type and add it as an optional association (the post type holding the repeater would then be the child). But I'm not the only one who will be using the admin pages for my custom post types. And some people, they really don't want to have to navigate away from the parent's post type to the child's.
Thank you!
Stuart Simon
Graphics Specialist
LSU Human Development Center
411 S Prieur St
New Orleans, LA 70112
http://www.hdc.lsuhsc.edu/
From: Simon, Stuart A.
Sent: Tuesday, February 21, 2017 12:34 AM
To: michaeluno/admin-page-framework <[email protected]>
Subject: Re: [michaeluno/admin-page-framework] Repeated section of length of zero (#266)
I thought I should be more succinct.
A repeating group named "group1" has two child fields, "field1" and "field2." When saved to the database, the data represented by the entries in the repeating group will be serialized thus:
$_POST['group1'] = array(
0 => array(
'field1' => 'foo',
'field2' => 'bar'
),
1 => array(
'field1' => 'Lorem'
'field2' => 'ipsum'
) ...
)
In other words, the repeating group is always bound to a non-associative array in the data. What I am asking for is the special case that the repeater is bound to an empty array. The repeater in this case should have zero entries (where an "entry" may be called a "group" or "row" ). In my mind, all that is needed in the repeated group's DIV in that case should be the button that adds an entry.
What I can do is to show you how those of your competitors have handled the special case of a repeating field with zero entries.
…Sent from my iPhone
On Feb 19, 2017, at 7:19 PM, Michael Uno <[email protected]<mailto:[email protected]>> wrote:
*EXTERNAL EMAIL: EVALUATE*
Hi Stuart,
What I need is to allow my repeating group to have zero length.
I don't understand this part. Can you elaborate?
-
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#266 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ATRYOHMUDzA3byP8niUNTyw1u6YgvR2dks5reOocgaJpZM4MAG8E>.
|
Hi Stuart, Sorry for the late response. It sounds like a good option to have. However, I cannot guarantee when it is implemented. As for the email you sent via the contact form, indeed I have missed it. I'll respond to it in email. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello.
My name is Stuart Simon. I am trying to write a plugin that adds a meta box that allows users to add files with descriptions to a post type. What I need is to allow my repeating group to have zero length. I cannot set any of the fields in my repeating group to be required because at least one record is always there. The key is that this is bad data design. I don't want meaningless records clogging my database.
I want to use your plugin because it allows adding custom attributes to its fields. I don't remember if nested repeatables are supported, but I thought of plugins other than CMB2 that allow me to set field attributes directly. ## Type of issue
Prerequisites
dev
branch.Steps to reproduce the issue (for Bug report)
Expected behavior and actual behavior
When I follow those steps, I see...
I was expecting...
Environment
Browsers
Operating System
Versions
Isolating the problem
The text was updated successfully, but these errors were encountered: