Comments (7)
We discussed solving this using a dual approach:
- Adding a key
'index' => true
to a field, which will add a new post meta entry for the field. The field's data is still stored within and accessed through the group's serialized data; the index is used only for meta queries. - Adding a key
'use_individual_keys' => true
to a group, which will set the fields within that group to solely use their own keys. Note that this approach will not work on every field type, and requires the developer to know what s/he is doing.
Considerations:
- Fieldmanager_Post stores a struct, not a single integer. Need to add an option to store a single integer.
- For the second approach, a few field types won't work here, and should throw an exception (specifically: sortable fields, repeating groups, posts not storing as integer)
from wordpress-fieldmanager.
For what it's worth, 'index' => 'indexname' is now supported. I have no problem supporting the second approach here, but probably won't build it myself.
Also, Fieldmanager_Post is about to be removed from Master.
from wordpress-fieldmanager.
I'd love the latter. Storing meta values coupled to their presentational structure doesn't make much sense, imo.
from wordpress-fieldmanager.
The latter could be added as an option, certainly. Now that Fieldmanager uses contexts (it did not at the time that this issue was opened) it would be much easier to implement an alternate storage pathway as a subclass of Fieldmanager_Context_Post, or maybe pass a flag to the context 'field_names_as_keys'.
Also, I think we could preserve total functionality and avoid crazy exception detection by only storing the root field names as separate keys. If any of the fields are groups, they get stored as arrays like normal, just up one level basically.
Come to think of it, it's probably pretty trivial to implement and test.
Although to your point about presentational vs logical structures, I think it really depends on the use case. Once you're dealing with repeatable fields, I think bulk storage makes much more sense. In the meantime, I would direct you to 'index' which will still be useful in both scenarios since it enables querying on any meta value, including those of repeatable fields. (Have I complained that postmeta allows dupe meta_keys but lacks an 'order' column before? No?)
from wordpress-fieldmanager.
I've enabled this in branch store-each-field-as-meta
if you want to test.
from wordpress-fieldmanager.
Needs unit tests before PR/merge though
from wordpress-fieldmanager.
Thinking about a spec for the "store-each-field-as-meta" feature:
- Repeatable fields can be supported. To do this, we should
delete_post_meta( $post_id, $this->fm->name )
, thenadd_post_meta()
- With the above, I think we can support sortable fields as well. I don't know offhand that order is guaranteed, so we'll need to test that.
- We could hypothetically support group children. I see it being possible if we made the key representative of the hierarchy, concatenated by underscore or hyphen. This wouldn't work with children of repeatable groups, and I'm sure there will be other cases where it doesn't work, but it's worth exploring.
from wordpress-fieldmanager.
Related Issues (20)
- Improve escaping of validation JS
- Autocomplete validation doesn't work HOT 1
- jQuery Validator issues with repeaters HOT 1
- Yoast SEO Compatibility Issue HOT 2
- Fieldmanager_Radios used as conditional source don't work if validation fails HOT 1
- Conditional visibility but unconditional validation HOT 4
- Hash Fieldmanager_Password values? HOT 2
- UI Issues HOT 3
- Admin menu page stopped working after PHP 8.0 update HOT 2
- Prevent saving values when they are the default value
- Using an image as a Fieldmanager_Radios label HOT 2
- Data not saving if FieldManager enabled in conditional check
- Repeatable fields with nested FM Groups prevent proper saving HOT 1
- Modifying values before save HOT 1
- MenuItem Fields: FM field styling blocks editing the menu item's label
- Custom attachment meta fields not displaying when new image is uploaded HOT 2
- Test suite needs to be updated HOT 1
- TextArea and RichTextArea fields cause a warning in PHP 8.1 HOT 1
- PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated HOT 1
- Resolve PHP Deprecations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wordpress-fieldmanager.