Jump to content


  • Posts

  • Joined

  • Last visited

Federico's Achievements

Sr. Member

Sr. Member (5/6)



  1. Thanks @Zeka and @bernhard for some reasons the code posted by Bernard gives an error, even if starts with $this->wire->addHookAfter instead of just $wire->addHookAfter maybe because the form name declaration in this method (I did not know, can you actually declare the form name in that?) InputfieldForm(name=form-application)::processInput Anyway, I have solved this minor issue with the approach as per the Zeka suggestion. Thank you both
  2. Hi @Zeka In the code above I have the POST input check, as follow: if($this->input->post->hook_accept_application){ wire('session')->redirect(wire('pages')->get(123)->editUrl; } which works. However, for a more articulated module development I am looking for a hook method to fire a function when the form named "form-application" is submitted. In other words, I am looking to wrap it into a function like the following one. Any idea? public function addButtonsMethods($event) { if($this->input->post->hook_accept_application){ wire('session')->redirect(wire('pages')->get(123)->editUrl; } }
  3. Hi, here is my attempt in short. I want to hook the submitted form in custom admin module and fire a function if conditional applies. Problem: I cannot find a working hook to check if a form has been submitted. I would like to fire the addButtonMethod function if the form "form_application" is submitted by the "hook_accept_application" button. I know it sounds basic, but I have tried all of the following without success. Thanks a lot for the help public function init() { parent::init(); $this->addHookBefore('InputfieldForm::processInput', $this, 'addButtonsMethods'); $this->addHookBefore('InputfieldWrapper::processInput', $this, 'addButtonsMethods'); $this->addHookBefore('InputfieldSubmit::processInput', $this, 'addButtonsMethods'); } public function ___execute() { $modules = $this->wire('modules'); $form = $this->modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", "form_application"); $btn_application_create = $this->modules->get("InputfieldSubmit"); $btn_application_create->attr('id+name', 'hook_accept_application'); $btn_application_create->value = "Start Student"; $btn_application_create->addClass("ui-priority-primary button_submit"); $form->append($btn_application_create); return $form->render(); } public function addButtonsMethods($event) { if($this->input->post->hook_accept_application){ wire('session')->redirect(wire('pages')->get(123)->editUrl; } }
  4. Just a quick question, as I wasn't able to find any answer over this tread: is the scf module capable of manage file uploads (therefore send email with attachments)? Because my form gets error as soon as I attach a fileUpload fieldtype to the form, so no way for me to manage it Much appreciated
  5. Hi, is there a clean way (not touching the module) to get fields labels instead of fields name in the email content text? //Line 464 foreach ($this->allFields as $inputfield) { $message[] = $inputfield .': ' . $this->sanitizer->textarea($this->input->post->{$inputfield}); } to something like this (not working...)? //Line 464 foreach ($this->allFields as $inputfield) { $message[] = $inputfield->label .': ' . $this->sanitizer->textarea($this->input->post->{$inputfield}); } thanks! --- Amendment: Here's how I've approached to get this done, maybe someone else might be interested: $message = array(); $message[] ='Some description...'; $message[] = '---'; $message[] = 'Name Surname: ' . $input->post->mail_name; $message[] = 'Partecipa il 7 Luglio? ' . ($input->post->mail_option_01 == 1 ? 'Si.' : 'No.'); $date = new \DateTime(); $message[] = 'Date: ' . $date->format('Y-m-d'); $emailText = implode("\r\n", $message); // in option array 'emailMessage' => $emailText, Cheers!
  6. @elabx that's great, I've just tested in ready.php and it works as expected. Good hook! I was getting close to this but I didn't know about the possibility to ad executeSomething right in the hook method. Thank you!
  7. Hi there, adding a function in ready.php (like I normally do in custom module) throws an error, for obvious reasons. How can I implement a hookable url within the ready.php (admin side)? for instance, if I hook a pageLister execution to add a button to it like this: $wire->addHookAfter("ProcessPageLister::execute", function($event) { if(wire('page')->id === 1413) { // the particular Lister instance page id $out = $event->return; $out .= ''; $btn = wire('modules')->get("InputfieldButton"); $btn->attr('data-href', "./addNewRecordal"); $btn->addClass("pw-modal"); if(!$this->config->ajax) $out .= $btn->render(); $event->return = $out; } } How can actually create a virtual url for that button? in a custom module it can be achieved like this: public function ___executeAddNewRecordal() { // // Create new page and redirect to its edit section $p = new Page(); $p->template = '02_template'; $p->parent_id = 1040; $p->name = 'recordal_' . $pageRecordalsMicrotime; $p->title = 'Recordal_' . $pageRecordalsMicrotime; $p->created_users_id = $this->user->id; $p->of(false); $p->save(); $this->session->redirect(wire('config')->urls->admin."page/edit/?id={$p->id}&modal=1"); } ..but in ready.php this is not possible. The tricky thing is that I have to hook a modal, I think, and this is not achievable via PHP afaik. Any hint? thanks
  8. Hello, I'm sure it requires a simple hook to hide the entire Pages tab in admin (for non-superusers), but none of the post in this forum nor the hooks directory seem providing an answer as far as I know. looking for adding the hook in ready.php, like this example $wire->addHookAfter('Page::listable', function(HookEvent $event) { // BUT I AM LOOKING TO HOOK THE ENTIRE TAB CALLED PAGES, NOT JUST THE LIST INSIDE $page = $event->object; $user = $this->user; if($this->wire('user')->hasPermission('example')) { $event->return = false; } }); someone more experienced? thanks a lot
  9. Hi @bernhard, my use case is to find this type of hook for the main navigation and prepend or append something to it. In Reno Admin theme (but also in the default admin theme too) we could achieve this with the following code $wire->addHookAfter('AdminThemeRenoHelpers::topNavItems', function($event) { $out = $event->return; $out .= '<li><img src="path/image.png"></li>'; $event->return = $out; }); Whereas you cannot leverage a similar hook to the Uikit theme (the latter soon to be the default theme). Am I correct?
  10. Hello pw community, is it possible to add some hook functions to the Uikit theme as well? I see all others themes (default and Reno) have extensive hooks capabilities, whereas the Uikit based theme in the admin has only the ___breadcrumb available. I am looking specifically to hook the masterhead navigation, but I believe the array of requests might be larger. I was discussing this on another thread @ryan sorry to bother you, maybe you already gave it some thoughts about. Do you think this will require intense work? Thank you very much!
  11. At the moment the only way to achieve this in the Uikit Admin Theme is via javascript route, as described by Lahijani in this thread
  12. well after many attempts, I've found that this working solution doesn't work for the Uikit Admin theme, as the latter has no helper file (yet, whereas all others admin theme have). pity!
  13. Looking for suggestions on how to insert a dropdown menu next to the admin navigation (Pages, Setup, Modules, Access, DropdownMenu), with uikit3 will be something like this one I see how to hook and modify the module page title and the breadcrumb $this->addHookBefore('Process::execute', function (HookEvent $event) { $process = $event->object; $event->wire('breadcrumbs')->removeAll(); $event->wire('processHeadline', 'customTitle'); $event->wire('processBrowserTitle', 'customTitle'); }); but not sure how to hook the main navigation to add new item. I see this executeNavJson in the Hooks methods, but doesn't return enything $this->addHookBefore('Process::executeNavJSON', function (HookEvent $event) { $process = $event->object; // @var Process $process bd($process); // Tracy is not even thrown }); Did I miss any docs for this?
  14. Hi there, sorry for raising this up, but I think it is not entirely correct to leave this as "solved", because I've just discovered that all the hook code above will actually add new <form> tag for each repeater, leading to a code mess and nested forms.. $this->pages->addHookAfter('Inputfield::render', function (HookEvent $event) { //$page = $event->arguments(0); $field = $event->object; //substr takes the first 13 letters to match the repeater_item if (substr($field->name, 0, 13) === 'repeater_item' && $this->page->name === 'book') { $id = str_replace('repeater_item_', '', $field->name); $form = wire('modules')->get("InputfieldForm"); $repeaterBtn = wire('modules')->get("InputfieldButton"); $repeaterBtn->attr("value", "Generate Brochure in panel"); $repeaterBtn->attr("type", "button"); $repeaterBtn->attr("id+name", "button_form_$field->name"); $repeaterBtn->attr("data-href", "./testa/"); $repeaterBtn->addClass("ui-priority-secondary "); $repeaterBtn->addClass('pw-panel button_export2pdf'); $form->append($repeaterBtn); $myForm = $form->render(); $event->return .= $myForm; } }); by calling Inputfieldform here, eventually the module will load these new button in a new form tag, the latter nested into the main form tag room for improvement?
  • Create New...