Comments (3)
Hi and thanks for trying the framework.
Actually you don't need to create a custom field in order to build relationships between custom post types. You can easily do it with a very small amount of code.
I invite you to check the code of the framework website here on Github as we've built a select field filled with page posts (which can easily be replaced by custom post types):
Take a look at this file home.php
around line 21 to 26:
As you can see, there is a call to Field::select() and we pass an array filled by a custom model (a PageModel
class that retrieve/update datas).
Then look at the code inside the PageModel
class for the PageSelection
method. We simply run a new WP_Query and return an array where each key is the ID and the value is the post_title:
Then you get a custom relationship field with better logic separation and the model class and its methods can easily be re-use anywhere in your application ;)
Also I checked your code and at this state, I will reject your pull request because:
- What you're looking for can easily be achieved like the example above.
- You hardcoded a
listing
custom post type and this is not giving any flexibility for developers.
For your project, please check the website code and if you need more help or more information, don't hesitate to ask ;)
Regards,
Julien
from framework.
:) I knew there had to be a better way to go about it. I also intended on cleaning it up. Thanks this is awesome and super helpful. Long live themosis.
-thanks
from framework.
Hi! I can't seem to view the code for building a relationship field. The website repo seems to have been deleted already. How do you make a relationship field?
from framework.
Related Issues (20)
- Class DateField missing
- Metabox Field rules error message not showing up HOT 3
- Test (phpunit) has no access to config HOT 3
- Oddity in the Form handleRequest method HOT 7
- Trait 'Themosis\Core\Events\Dispatchable' not found HOT 1
- Themosis throws ErrorException for deprecations HOT 2
- themosis stores the node folder in the database HOT 2
- Defining routes to a controller, Reflection errors HOT 3
- Php artisan don't working after upgrade HOT 5
- Custom prefix routes in RouteServiceProvider.php
- User can directly access the theme directory
- Publish problem HOT 4
- Route controller declaration using array syntax
- Problem with connection after "vagrant up" command HOT 1
- Class FatalThrowableError not found
- Easy way to create Gutenberg blocks
- Wrong Twig Template Loading Order (App vs. Theme)
- Class \"Illuminate\\Foundation\\Bus\\PendingChain\" not found HOT 3
- Properly way to use form class and AJAX class
- Route using template not working HOT 1
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 framework.