Search the Community
Showing results for tags 'save'.
-
Hey guys, I'm having a hard time troubleshooting this one: my multilanguage fields save data outside repeaters, but inside any repeater they just won't save, unlike all other fieldtypes. What I've tried so far: Recreating the repeater matrix from scratch — problem persists Using multi-language fields on a regular repeater instead of a repeater matrix — problem persists Removing all language support modules and reinstalling — problem persists If I change the multi-language fields into single-language types, they start saving right, but if I change them back to multi-language, the problem persists. Changing the multilanguage field via API `$page->repeaterfield[0]->setAndSave("title","Meow")` — works, but I need it in the admin form To try to figure out the problem I did this: $wire->addHookAfter("Pages::saved(template=repeater_content)", function($event) { $page = $event->arguments(0); $changes = $event->arguments(1); $values = $event->arguments(2); bdb($page); bdb($changes); bdb($values); }); The hook is only triggered when I also change a non-multi-language field. On the dumped $page the title field is there like I changed it in the form. But something must happen after Page::saved that restores it back to what it was. Where would you look next to find the solution...? Thank you very much for your help!
- 3 replies
-
- repeater
- multilanguage
-
(and 1 more)
Tagged with:
-
Hi guys, the field "redirect_last" of type DateTime got not updated. The update on the field "redirect_counter" works and got saved. Does anybody know what I did wrong in my code? if ($input->urlSegment(1) === 'redirect') { $page->of(false); $page->redirect_last = time(); $page->redirect_counter += 1; if ($page->save('redirect_counter')) { $session->redirect($page->website_url, 302); } } Thanks.
-
I have a page that contains a single ProFields table field and I want to display the contents of the table on the front end and then for logged in users, they can edit certain columns in the table. What I have at the moment is $out = '<form action="'.$page->url.'" method="post" > <table class="table"> <tbody>'; $count = 1; foreach($page->fieldName as $row) : $out .= ' <tr> <td><input type="checkbox" name="fieldName_'.$count.'_columnName"></td> </tr>'; if($input->post->submit) : $page->of(false); $page->set('fieldName_'.$count.'_columnName', $sanitizer->text($input->post->{fieldName_'.$count.'_columnName})); $page->save(); endif; $count++; endforeach; $out .= ' </tbody> </table> <button class="button" type="submit">Save</button> </form>'; The two problems I have are: I get an error trying from $sanitizer->text($input->post->{fieldName_'.$count.'_columnName}), not sure how to make that dynamic. If I change the above to just a static value, e.g. $page->set('fieldName_1_columnName', 'Testing') and save the form, it's not saving the values to the database. Where am I going wrong?
-
Hello forum! I've yet again stumbled on a head-scratching situation. We have enabled the option on our articles template and events template that it skips the title adding part and goes straight to the form. This is what our customer wants. So when you add a new article or event it automatically names it temporary to "article-0000000" and same with event. Now the problem is that obviously after saving the form we want to change to page url or "name" to the title, like it's normally. Now here's the code for the hook: wire()->addHookBefore("Pages::saved(template=tapahtuma|artikkeli)", function($hook) { $page = $hook->arguments(0); $newUrl = wire()->sanitizer->pageName($page->title); // give it a name used in the url for the page wire()->log->message($page->name); $page->setAndSave('name', $newUrl); }); I get the correct page and the name and path changes when I log them, but when I try to save it. It just loads and then I get: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) This happens in sanitizer.php and then another error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0 What is happening? Am I not suppose to use sanitizer in this way? When we made a temporary page object in out other hook, the sanitizer worked perfectly. Thanks for the help!
-
So I have been diving into hooks lately, and I am enjoying them thus far. However, I guess I am a bit stumped on how to achieve what I want too. I am trying to set up a hook that would create a new child page when the parent page is saved. However, when you save the parent page a second time, I just need to update the child page without creating multiple child pages. What would be the best way to go about this? So after rereading my post, I believe it is a bit vague so I will try to explain more. The Goal: Create a page with a template "one". Once the page is created/saved => create a new child page with the template of "two" If the parent is saved anytime after, do nothing to the child page (limit the parent page to one child page) The parent page is really just being used to output content, whereas the child page is being used to pull out the some fields from the parent to be used elsewhere. I might have made this too complicated in my head.
-
I have a page with a good amount of fields on it, I have many other pages in the same template that have no issue, but one particular page just doesn't save changes to any of the fields. I installed the clone page module, cloned the page, and everything cloned fine... but still when i try to make changes to the clone nothing saves either (just like the original page). I expect some kind of notification to show up saying it saved, or not, but i get nothing as if the page reloaded fresh. The failure is silent, and there's nothing in the logs to direct me. This is a real head scratcher and I'm not sure how I should go about troubleshooting it further. Can someone help? Thank you kindly.
- 4 replies
-
- solved
- silent failure
-
(and 2 more)
Tagged with:
-
I was curious, is it possible to exclude the addHookAfter("saved") from running when copying pages. I have a function (currently running in ready.php) that runs on page save for certain templates. $pages->addHookAfter('saved', function($event) { $page = $event->arguments[0]; if($page->template->name == 'dev' .... The function basically just adds the page title to a csv using fwrite if the name does not exist yet. This is functioning great, however, it also runs when copying the pages which produce some unwanted results, ie: dev-page dev-page-1 (the title of the copied page before I have a chance to rename the title and name). I end up with a bunch of *-# pages, as well as the new page names/titles. Is it possible to somehow get around the copying also running the function?
- 3 replies
-
- copying
- addhookafter
-
(and 2 more)
Tagged with:
-
Hi, I'm stuck since hours and don't know what to do. Here is my Problem: I try to generate Previews of PDF using imagick. I have 4 PDF, I generate a preview of the first page of the pdf, save it to a temporary file and want to import it using the api into an image field. It works for the later 3 pdf but not the first. I add it to the image field and save it. Inside the function that saves it, the image is stored in 'data' as well as in 'itemsAdded' but as soon as i leave the function, its nowhere to be found. Process: 1. create previewimage using imagick and create Pageimage > works 2. add image to filed 'filepreviews', returns Pageimages array with image added > okay 3. save page > returns true 4. Outside renderPreview method, image is not anymore in 'filepreviews' // mymodule // … // foreach($files as $file){ $preview = wire('page')->filepreviews->get('name*='.$file->basename(false)); // if there is no preview image… if (!$preview instanceof Pageimage) { $this->renderPreview($file) // we create one using $this->renderPreview > should return true on successful save dump(wire('page')->filepreviews); // my Image is nowhere to be found $preview = wire('page')->filepreviews->get('name*='.$file->basename(false)); } // end for each // render a preview of an otherwhise not supported file format // return true if sucessfull save private function renderPreview($file) { $page = wire('page'); // get path to temporary image $tempFile = $path.$file->basename(false).'-preview.jpg'; // … some imagick code // … and save it: $imagick->writeImage($tempFile); $img = new Pageimage($page->filepreviews, $tempFile); $img->description = $file->basename(false); // destroy temp image unlink($tempFile); // this is my Pageimage, all good… dump($img); // save image, my Pageimage can be found in data and itemsAdded – all good dump($page->filepreviews->add($img)); $page->of(false); $success = $page->save(); // sucess = true dump($success); return $success; } Second question: Would there a generally better approach? Like using pageFiles somehow. Goal is to be able to use the image api like scale etc – I don't generally need the images to be stored in an image field.
-
Hi all, Im a bit confused by an issue I have come across today. I have a module which connects to a third party (once an hour using LazyCron), parses a publicly available XML file, turns it into useable information which I then use the API to save as PW Pages. On the whole this has been working great however today I noticed that it kept failing on one of the imports. After doing some investigation I realised its appears to be dying at the save page stage. From the documentation $page-save() should return either True/False, so I thought I would update the code to reflect this while debugging. $this->log(1); $bool = $p->save(); if($bool){ $this->log('Saved successfully'); } else { $this->log('Fail to save'); } $this->log(2); However the script only gets to the save() part and then appears to terminate. Then when checking the error log the latest entry is always just '1' Any ideas as i'm a tad confused why I at least don't get a response of some kind?
-
In response to a wishlist request... Field Save + Add New Adds a "Save + Add New" button when editing a field. Usage Install the Field Save + Add New module. When editing a field, click "Save + Add New" if you want to save the current field and start the process of adding a new field. Note: The button will not redirect you to "Add New" if you are performing some special action such as duplicating a field or adding a field to a template. https://github.com/Toutouwai/FieldSaveAdd/
-
I've recently had a problem crop up with pages using a certain template that was working fine before. When I go to edit certain pages, I get returned to the same page I'm on, i.e. /processwire/page/edit/?id=XXXX but instead it displays the 404 template. And the data I'm entering or updating doesn't get saved. The template only has title, multiplier, table and file fields attached to it. And the table field is also modified by the TableCSVImportExport module. And it only seems to be happening to certain pages with this template, not all of them. :?
-
Hello, Just a simple (I think) question which is in the title of my post. Roughly speaking : here's my code (made-up because my real function is so long... I don't want to post it all here ) function updateScore($player, $task, $real = true) { [...] $player->score = $player->score+$task->score; if ($task->name == 'new-equipment') { $new-eq = $pages->get("name=sword"); $player->equipment->add($new-eq); } if ($real == true) { $player->save(); } } Everything works fine when I call updateScore($player, $task, true), but if I call updateScore($player, $task, false), scores are untouched, but the equipment gets added ! It used to work fine on PW2.7 but my update to PW 3.0.62 seems to have broken this... Is there a simple explanation ? I keep reading my code over and over and this is driving me crazy... Thanks !
-
AddHookAfter("save"...) on Page template ==("")
Mathroth posted a topic in Module/Plugin Development
Greetings to all processwire fans, I am new in processwire and I have used it since 3 weeks. Probably it's a really silly question but does someone now how I can execute a function in my own module, which is triggered when I save a pages, which contains a user-defined template. I tried to to this with an basic if/else condition to trigger the hook when the page has theTemplateName== "". Unfortunately it doesn't work. So I try this which might be the wrong Syntax. Perhaps someone can give me a hint THANKS a lot! public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->page->template == "templateName"->addHookAfter('save', $this, 'example1'); } -
Code below works everywhere else, except if applied to pages in Admin tree. Specifically, I change parent to some 'user-car' pages and place them under some 'user' page in admin tree. $page->of(false); $page->parent = $some_user_page; $page->save(); $page->save() freezes, e.g. method does not not return any value/looks like in falls in endless loop somewhere inside. It also does not generate any errors. As it happens only in Admin tree (everywhere else it works), root cause could be: (1) in template settings (I've checked and didn't found any "restrictions", e.g. 'user-car' pages can be freely moved, 'user' may have children) or (2) in core code, somewhere in Page::save() Please, advise how to fix this issue.
-
Hi Guys I am trying to save Pages with the API from the root Folder in a file named refreshIndex.php. The code looks like this: $root = "/path/to/root"; include($root . "index.php"); //$doctors = wire('pages')->find("template=doctors"); $jobs = wire('pages')->find("template=jobs"); //$news = wire('pages')->find("template=news"); //$specialities = wire('pages')->find("template=specialities-clinics"); //$events = wire('pages')->find("template=signup-form-formbuilder"); //$dbpages = wire('pages')->find("template=doctors|specialities-clinics|news|signup-form-formbuilder|jobs"); //$allpages = wire('pages')->get(27200)->find(""); foreach ($jobs as $stpage) { $stpage->save(); } Now at the moment I am trying to save Job Pages. They are 2 job pages right now. It saves 1 of them and at the 2 one I get an Error like this: Error: Uncaught WirePermissionException: Page '/de/jobs/test-job_ge/' is not currently viewable. in /pathtoroot/wire/modules/PageRender.module:319 They are both using the same template with the same permissions respectively they are visible (guest user is viewable). And also the languages of the page are all active inside page settings. Somehow my Hook is responsible for this. The hook is the reason for my Script above. I am trying to update the index field for my site search. The hooks works fine when I am saving the pages from the backend interface, but I can't save all pages from the backend since they are over 1500 pages I need to save. $this->addHookBefore('Pages::saveReady', $this, 'hookIndexingBefore'); protected function hookIndexingBefore( HookEvent $event ) { $options = array(); $page = $event->arguments("page"); // abort when true if(!$page->template->hasField("index")) return; if($page->isNew() || $page->isTrash()) return; // save user lang $language = $this->wire("user")->language; // clear index field at the begin $page->index = ''; if($page->is("template=specialities-clinics")){ $options['sender'] = $page->choose_sender_2016->id; } $options['pagename'] = $page->name; foreach($this->wire("languages") as $lang) { $this->wire("user")->language = $lang; // change user lang wire('pages')->setOutputFormatting(true); $content = $page->render($options); wire('pages')->setOutputFormatting(false); if($content){ $startStr = "<!--### start-indexing-area ###-->"; $endStr = "<!--### end-indexing-area ###-->"; preg_match_all('/'.$startStr.'(.*)'.$endStr.'/siU', $content, $matches); $newContent = preg_replace("/<div class='breadcrumb.*'>.*<\/div>/siU", '', $matches[1][0]); $newContent = str_replace('<', ' <', $newContent); $newContent = strip_tags($newContent); $newContent = preg_replace("/\s\s+/", " ", $newContent); } $page->index .= $newContent; } $this->wire("user")->language = $language; // restore user language }
- 2 replies
-
- save
- permissions
-
(and 1 more)
Tagged with:
-
Hi Guys This hook works fine. $this->addHookAfter('Pages::saveReady', $this, 'hookIndexingBefore'); protected function hookIndexingBefore( HookEvent $event ) { $page = $event->arguments("page"); if(!$page->template->hasField("index")) return; // no index field in this page/template if($page->isNew() || $page->isTrash() || $page->indexSaveFlag) return; $language = $this->wire("user")->language; // save user lang $page->index = ''; foreach($this->wire("languages") as $lang) { $this->wire("user")->language = $lang; // change user lang wire('pages')->setOutputFormatting(true); $content = $page->render(); // render page and get the content wire('pages')->setOutputFormatting(false); if($content) $content = $this->parseContent($content); //remove html, new lines etc... $page->index .= $content; } $page->indexSaveFlag = true; // in case it get's saved again (not case with Pages::saveReady) $this->wire("user")->language = $language; // restore user language } But when I try to save a page per api I get an Internal Server Error 500. When I replace "$page->render();" with "" inside the hook, it doesn't cause a internal server error anymore. $page->save(); //causes internal server error now
-
Hi, I have a PageTable field that contains fields that I need populate with values from fields in the containing page when the page is saved. I've tried to do this with a module but I can only get the fields to populate when it's saved for a second time (or saved after publishing), which is not ideal behaviour. Here's my code: public function init() { $this->pages->addHookBefore('save', $this, 'AddWorkReferenceQuote'); } public function AddWorkReferenceQuote($event) { $page = $event->arguments(0); if($page->template == 'media_wall_quote') { if($page->id) { $work_page = wire('pages')->get("template=work, media_wall_work=$page"); $page->media_wall_work_ref = $work_page->work_ref_id; I think the issue is: $work_page = wire('pages')->get("template=work, media_wall_work=$page"); Which doesn't returning the PageTable containing page on first save/publish. I've tried changing the hook to addHookAfter but this has no effect and stops it from working altogether. Anyone have an idea how I can access the containing page of a PageTable page before save?
-
Hi, I've created a simple module that does the following: Checks if a checkbox is ticked ('media_wall_quote_hero') on a page using the template 'media_wall_quote'. If that checkbox is ticked, it adds that page to a PageTable field ('quotes_hero') located on the 'home' template. If it's not checked and the page is in the PageTable field it is removed. It all works correctly when checking/unchecking the box on pages using the 'media_wall_quote' template in admin. However, if I edit the pages in the PageTable field itself on the homepage in admin, when I save the modal, the PageTable field is not updated. Strangely if I uncheck it (ie. when it should be removed) the PageTable field says 'item added'. Is there a way I can hook into the PageTable field when the modal is saved and update it so if I check/uncheck the box it does the correct action? public function init() { $this->pages->addHookAfter('save', $this, 'AddRemoveHeroQuotes'); } public function AddRemoveHeroQuotes($event) { $page = $event->arguments(0); if($page->template == 'media_wall_quote') { $home = wire('pages')->get(1); $home->of(false); $work_page = wire('pages')->get("template=work, media_wall_work=$page"); // If this quote is a (published) hero quote add it to the pagetable field if($page->media_wall_quote_hero == 1 && !$page->is(Page::statusUnpublished)) { if(!$home->quotes_hero->has($page)) { $home->quotes_hero->add($page); } } // If this quote is a not a hero quote or is unpublished remove if from the pagetable field elseif($page->template == 'media_wall_quote' && $page->media_wall_quote_hero == 0 || $page->template == 'media_wall_quote' && $page->is(Page::statusUnpublished)) { if($home->quotes_hero->has($page)) { $home->quotes_hero->remove($page); $this->message('removed'); } } $home->save('quotes_hero'); } }
-
Hey, I made a hook that is triggered when a page with a certain template is saved. I meant to create the script only for the backend of the website. Now, whenever a page is saved on the front end (with the API) the module is being triggered. I was wondering if there is a method to have it only trigger whenever a page is saved on the backend (so not through the API). Jim
-
Hi all, I'm having trouble saving a table field modified programatically. I tried save() on the page but the change isn't being saved. Here is the code: foreach ( $event->event_data as $ed ) { // update the signup id so we don't have to look for the file again if ( $signup_id != 0 ) { var_dump( $ed->signup_id ); $ed->signup_id = $signup_id; // $event->save( $event->event_data ); $event->save(); var_dump( $ed->signup_id ); } The two var_dumps() produce this output: NULL int(8045148) This tells me that the field is being set to the correct value. However, when I visit the page, the signup_id field is still NULL (that is, nothing is displayed). $event is a page, $event->event_data is a table, and signup_id is one of the table columns. Thanks for any help! Julio
-
Hello everyone! I'm not sure the right thread is chosen, but anyway I'll continue. My pages structure looks like Category->Subcategories->Pages A task is to make PW to count Pages,when their amount is changed and write it to the Subcategory's and Category's appropriate field regardless of Pages amount change is made from admin of template. So I'm trying to hook into 'save', 'trash', 'restore' and 'delete' methods from within a site module. 'Save' hook seems to work fine, but hooking into 'trash' requires to track Page->parent and Page->parent->parent the the other way, because they are changed to 'Trash' and 'Root' when 'trash' execution is is finished. The other words, at the moment when I have to count Pages in Category and Subcategory, where the Page was 'thrashed' from, there is already no way to determine, what the Category and Subcategory contained this Page. I'm trying to hook into 'trash' before execution, find Page Category and Subcategory and assign them to an module object property, so after the 'trash' execution I can hook into it again and count Pages in Category and Subcategory, saved in properties. But something causes my before 'trash' hook to execute two times: before and after 'trash', and as the result module object properties contain not Category and Subcategory, but 'Trash' and 'Root' pages. Here is my Code: public $country; public $region; /** * Initialize the module * */ public function init() { $this->pages->addHookBefore('trash', $this, 'prepareTripSave'); $this->pages->addHookAfter('trashed', $this, 'afterTrash'); } /** * Counts 'Trips' in 'Region' and 'Country' * */ public function countTrips($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { // do only when 'Country' and 'Region' are find if(count($this->country) && count($this->region)) { $this->message('ok'); $amount = $this->region->children("template=Trip")->count(); //count 'Trips' in 'Region' $this->region->setOutputFormatting(false); $this->region->amount = $amount; $this->region->save("amount"); // save only field $this->region->setOutputFormatting(true); $amount = $this->country->find("template=Trip")->count(); //count 'Trips' in 'Country' $this->country->setOutputFormatting(false); $this->country->amount = $amount; $this->country->save("amount"); // save only field $this->country->setOutputFormatting(true); } else { $this->message('nop'); } $this->message("Country: {$this->region->amount}; Region: {$this->country->amount}"); $this->region = ''; $this->country = ''; } } public function prepareTripSave($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { $this->region = $this->pages->get($page->parentID); // find 'Region' by 'Trip'->parentID $this->country = $this->region->parent; // find 'Country' as a 'Region'->parent $this->message("Before Region: {$this->region->title}; Country: {$this->country->title}"); } } public function afterTrash($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { $this->message("After Region: {$this->region->title}; Country: {$this->country->title}"); } } Thanks!
-
I have a simple module that creates a page when another page is saved with a checkbox field checked. My code below works well but I have one issue, it runs when the page is trashed as well as saved (creating an erroneous second duplication of the page). <? public function init() { $this->pages->addHookAfter('save', $this, 'dupeStandalone'); } public function dupeStandalone($event) { $page = $event->arguments[0]; if($page->template->name == "article_language" && $page->article_standalone == 1) { $a = new Page(); $a->template = 'article_standalone'; $a->parent = wire('pages')->get('/article/'); $a->name = $page->name; $a->title = "{$page->title} (standalone placeholder post for {$page->parent->parent->title}-only article)"; $a->save(); } } Could anyone help as to why it runs the function on trash as well as save?
-
Hi there, I've got some code that bulk uploads the contents of Tab Delimited files into our Processwire CMS. It looks like the $page->save functionality stops working after a certain number has been processed. Haven't worked out where it starts failing yet but all the rows towards the bottom have certainly failed. Unfortunately, there isn't anything in the error logs (at least the php error log) to see if there is an issue. I have tested the rows that were not working by putting them individually in seperate tsv files to prove that the code works, the data is clean and it actually updates the CMS. I was wondering if there's an internal limit on how many page saves the CMS can handle? Thanks in advance. Below is the copy of the code I'm using to do a bulk upload. I'm using a 3rd party module called SimpleExcel to help with the reading and processing of the tab delimited files. $_rowStart = 13; $_colTitle = 1; //A $_colMeta = 10;//J Meta Title = SEO Title $_colDesc = 11;//K $_colURL = 12;//L $_colURLnew = 13;//M $_colCanonical = 14;//N $_colAlt = 15;//O $_colKeywords = 16;//P $excel = new SimpleExcel('TSV'); $excel->parser->loadFile(__DIR__."/{$file}"); //$url = $excel->parser->getCell($_rowStart, $_colURL ); $row= $_rowStart; do { $title = $excel->parser->getCell($row, $_colTitle ); $meta = $excel->parser->getCell($row, $_colMeta ); $desc = $excel->parser->getCell($row, $_colDesc ); $url = $excel->parser->getCell($row, $_colURL ); $urlnew = $excel->parser->getCell($row, $_colURLnew ); $canonical= $excel->parser->getCell($row, $_colCanonical ); $alt = $excel->parser->getCell($row, $_colAlt ); $keywords= $excel->parser->getCell($row, $_colKeywords ); $internal= str_replace("http://sprachspielspass.de",'',$url); $page = wire(pages)->get("path=$internal"); //TODO: Error handling and logging if (!IsNullPage($page)) { $page->setOutputFormatting(false); $page->title = $title; $page->seo_title = $meta; $page->seo_description = $desc; $page->url = $urlnew; $page->seo_canonical = $canonical; $page->image_alt = $alt; $page->seo_keywords = $keywords; $page->Save(); WriteLog("{$internal} saved"); } else { WriteLog("{$internal} NOT FOUND!"); } $row++; } while (!IsNullOrEmptyString($url));
- 6 replies
-
- $Page
- Bulk Upload
-
(and 5 more)
Tagged with:
-
Hello, I am developing a module that lets a user create, modify and save a "TV Grid" (the schedule for a TV channel). Here you can view some images that illustrate the concept: https://www.google.com/search?q=tv+grid&tbm=isch Of course, those are just examples and do not represent my specific implementation, but with that I hope you get the idea. The module installs a template for a "channel" (among other things). The "channel" has a "Repeater" field, where I store the complete grid for that channel. The repeater (grid) contains repeater items (grid items) that represent a scheduled show, e.g. ["Friends", Monday, 1st show of the day, lasts 60 minutes]. The repeater field is hidden from the user if he/she tries to edit the channel page via the admin's page edition interface. The intended way to edit this TV grid is by using the module's page that I've developed, which provides a custom interface for creating, manipulating and saving the grid. This of course means that I'm doing many things programmatically. The problem is that the repeater items I'm creating via code using the user's input just WON'T save. I've made all the code changes I could think of, trying different stuff, without positive results. Looking at the database, I notice the following when I run my code: - The corresponding row for the repeater field in its table is updated/saved. - However, no new rows are created for the repeater item fields (e.g. TV Show, duration, day, etc.). Would you please help me out here? I'm becoming insane ... I've included some code below. /* * More code before this, ommited because it isn't relevant. */ // Get the channel object (a Page). $channel = wire("pages")->get($channelId); if(!$channel->id) { $this->error("Channel does not exist. Grid can't be processed."); return ""; } // We need to clean this channel's grid before working with it. // "channel" is the Page // "tvChannelGrid" is the Repeater $channel->tvChannelGrid->removeAll(); $channel->tvChannelGrid->save(); $channel->save(); // Save the page.*/ // Add the grid items received from the module's form to the channel's grid. foreach($tvGridData as $i => $item) { // "tvGridData" is an associative array with data received from a form. $showId = intval($item["tv_show_id"]); $duration = intval($item["duration"]); $day = intval($item["col"]); $row = intval($item["row"]); $gridItem = $channel->tvChannelGrid->getNew(); // this must be done according to the documentation. $gridItem->save(); // Save the newly built item. // Assign values to repeater fields. $gridItem->tvChannelGridShow = wire("pages")->get($showId); // FieldtypePage $gridItem->tvChannelGridShowDuration = $duration; // FieldtypeInteger $gridItem->tvChannelGridShowDay = $day; // FieldtypeInteger $gridItem->tvChannelGridShowRow = $row; // FieldtypeInteger $gridItem->save(); // Save the newly built item. $channel->tvChannelGrid->add($gridItem); // Add the new item to the repeater. } $channel->tvChannelGrid->save(); // Save the repeater. $channel->save(); // Save the page.