Kurbel Posted August 30, 2022 Share Posted August 30, 2022 Hey, I'm in the process of coding an event page, which will display reoccuring events (think: a monthly event with roughly the same itenerary every iteration, but potential for changes). When an editor creates a new event page, I'd like the values for certain fields prefilled with custom values defined elsewhere. I've toyed around a bit with both hooks and custom page classes, but did not get to a working solution. Hooking into "Pages::savePageOrFieldReady", I can set the values on first save, which is not too bad and somewhat close to the feature I had in mind. I would've thought that "ProcessPageEdit::buildForm" would work for prefilling the form, but the event object honestly left me a bit flabbergasted. How do I access the single fields, check for empty and fill the values if possible? With custom classes I'd have thought I could set the values in the constructor but this does not change anything in the form with a newly created page. Seems the constructor is not even called. So, what am I missing? ? P.S.: Why am I not setting the default values during render? Ideally I'd like the single events not to change anymore after being edited. Link to comment Share on other sites More sharing options...
flydev Posted August 30, 2022 Share Posted August 30, 2022 Hi, check the following thread, starting at this message (then read the whole thing) : ? And about locking a page before/after with your own logic: 1 Link to comment Share on other sites More sharing options...
bernhard Posted August 30, 2022 Share Posted August 30, 2022 Thx for the inspiration - this is for you ? 8 1 Link to comment Share on other sites More sharing options...
3fingers Posted August 31, 2022 Share Posted August 31, 2022 @bernhard, what can I say? A new star in born! ? Excellent video!For future reference I link here a post where you already explained the use of custom classes (with a slightly different approach for exposing the init() method inside the class). Btw, I already subscribed to your YouTube channel! Keep going! 1 Link to comment Share on other sites More sharing options...
bernhard Posted August 31, 2022 Share Posted August 31, 2022 22 minutes ago, 3fingers said: Excellent video! Thx ? 22 minutes ago, 3fingers said: For future reference I link here a post where you already explained the use of custom classes (with a slightly different approach for exposing the init() method inside the class). Thx for the reminder, I linked the post in the video description! Yesterday I implemented another way of doing the same principle into RockMigrations. RockMigrations has had the initClasses() method, but you had to call that manually and provide the correct namespace. With yesterday's update you simply let the custom page class use the MagicPage trait and RockMigrations will autoload the pageclass on boot and trigger init() and ready() on the correct timing. I didn't want to put that into the video though as it's a very young addition and I've already had to fix some things today. But it looks like a very promising approach to me ? 29 minutes ago, 3fingers said: Btw, I already subscribed to your YouTube channel! Keep going! Thx, I'll try my best. It's quite a lot of work, but it's fun. 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now