-
Posts
1,427 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Juergen
-
Specific fields will not be saved anymore on specific template
Juergen replied to Juergen's topic in General Support
Ok I have figured it out, but I think this is a bug. The field values will not be saved if an inputfield dependency "show only if" is set to the fields. After removing them the values will be stored. Does anyone experienced the same issue on a CKE field? -
Hello @all today I discovered a problem saving the introtext and body field in one of my templates. Saving these 2 fields works well in other templates. I have only the problem in one template. What I have tried so far (just to mention: ProcessWire: 3.0.52, PHP: 5.6.30, Server: Apache, MySQL: 5.5.54) Testing with different browsers Looking at the log files in asset/log folder (no relevant entries) Looking at Tracy (no error) Looking at PW debug without Tracy (no error) Disabling template specific Javascript Uncomment all lines in init.php and ready.php (so no Hook will be active on this template) I have discovered this problem at another field some time ago. Replacing this field with a new created one solved the problem. But in this case these 2 fields are part of every template, so I dont want to create a new one. Has someone an idea what I can do in addition to find out where the cause could be. I can change the value of these fields directly in the database - no problem. Then the values will be displayed properly at the backend, so the problem must be during the saving process of these fields (all other fields on this template will be saved correctly). Best regards
-
Manipulating pagetable field markup with Jquery
Juergen replied to Juergen's topic in General Support
-
Manipulating pagetable field markup with Jquery
Juergen replied to Juergen's topic in General Support
This hook works well on page load, but not after update of the pagetable field It is the same problem as the Jquery solution. I have replaced my Jquery manipulation with this hook -
Hello @all, I use a pagetable field for events as children. For better visibility for active and cancelled events I use Jquery to manipulate the output of the pagetable field. Active events are green and cancelled events are red (see screenshot) This is the Jquery code snippet: jQuery(document).ready(function() { $("#wrap_Inputfield_singleeventtable table tbody tr[data-filter*='aktiv'] td:nth-child(2) ul li").wrapInner('<span class="uk-badge active"></span>'); $("#wrap_Inputfield_singleeventtable table tbody tr[data-filter*='abgesagt'] td:nth-child(2) ul li").wrapInner('<span class="uk-badge cancelled"></span>'); }); This works well until I open a childpage via a link in the modal. After closing the modal the pagetable will be updated via Ajax. This is the point where the ready function has no longer impact on the manipulation. I am not very familiar with coding Jquery. Has anyone an idea which event could be triggered after Ajax update to manipulate the markup once more or if there is a better solution than Jquery ready function in this case. Best regards
-
It would be great if inputfield dependencies would support multiple conditions with OR (see: https://processwire.com/talk/topic/15495-inputfield-dependencies-possible-to-add-multiple-conditions-with-or/) For example: condition1=1||condition2=1 The OR operator could be for example "||" and the AND operator is ",". Best regards
- 1 reply
-
- 1
-
-
Inputfield dependencies: Possible to add multiple conditions with OR
Juergen replied to Juergen's topic in General Support
Thanks @Robin S thats true, I need it on change and onload, so its a job for a custom jquery in my adminscripts.js -
Inputfield dependencies: Possible to add multiple conditions with OR
Juergen replied to Juergen's topic in General Support
OK, thanks for the info. -
Module Module: RuntimeMarkup Fieldtype & Inputfield
Juergen replied to kongondo's topic in Modules/Plugins
Thanks @bernhard your solution works pretty well. -
Module Module: RuntimeMarkup Fieldtype & Inputfield
Juergen replied to kongondo's topic in Modules/Plugins
Hi there, I use this field type with translateable strings and it works. My problem is I cannot find where I could translate it in the backend. Example: Fieldname: calendarbox PHP code inside this field: The output in the backend works. Maybe I have to create the translateable file manually. Can anyone help me out? Best regards -
No its a notice - it only shows up as an error because I am running Tracy in strict mode. These are my settings:
- 31 replies
-
- 1
-
-
- module
- appearance
-
(and 2 more)
Tagged with:
-
- 31 replies
-
- module
- appearance
-
(and 2 more)
Tagged with:
-
Here is a tipp for you if you want to check for validation errors in inputfields before processing php code inside a Hook function. My goal was to run the code inside the Hook function only if there are no errors after processing the form in the backend. $pages->addHookBefore('saveReady', function($event) { $page = $event->arguments[0]; //count errors during input process $errors = $page->errors('all'); $errors = count($errors); if ($errors == 0) { ......//run your code } }); In this case I run a Hook before "saveReady" inside my ready.php. But I only want to run my php.code inside this Hook function if there are no errors in the form submission. So I need to check for errors in the form submission first. These 3 simple lines of code are necessary: $page = $event->arguments[0]; //count errors during input process $errors = $page->errors('all'); $errors = count($errors); The first step is to define the page variable $page; Second step is to get the error array Last step is to count the entries in the array to get the number of the errors Thats all! Afterwards you can use the number of errors in an if-statement to run the code only if there are no errors. Hope this will be helpful for someone.
-
- 6
-
-
Hello @kongondo thanks for the explanation. I have implemented your first version and it works well, means that it shows the error message at the top bar and next to the field. My previous attempts showed only the error message at the top bar and not next to the field. So using a session is not a problem. I only thought that the same process could be achived with simplier methods. Anyway, it works very well. I think it will be a good feature for PW if every field has a custom validation field in its field settings where you can add additional php code for validation and you will have access to the api variables.
-
Thanks @kongondo, I will give it a try. To me it seems a bit complex using sessions for this. I guess there will be another way, which works like an $input->post validation, but I am struggeling with this problem for a while. Its also unclear to me why $form->get("date_end"); doesn´t grab the value of the input field "date_end" after form submission Many thanks for your solution.
-
I took a look at https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module My code is $pages->addHookAfter("ProcessPageEdit::processInput", function($event){ $form = $event->object; $firstdate = $form->get("date_end");//date field 1 $lastdate = $form->get("recurringdateend");//field 2 $this->message("Datum: {$firstdate} "); }); But if I add this to my init.php or ready.php I dont get the value of date field 1 in the message. So it seems that after submission of the form the value will not be grabed. I only put the message line to the code to see if the hook works. I dont know what I should do: I use a hook after, I use processInput which is for processing input data, I use the form as my object and I try to grab the values of the form fields with the get() method - In my opinion this should be the correct way.
-
Ok, I have read the docs and I put the following code into ready.php $pages->addHookBefore('saveReady', function($event){ $form = $event->object; $page = $event->arguments[0]; if($page->template == "events"){ $lastdate = $page->getUnformatted("recurringdateend"); $firstdate = $page->getUnformatted("date_end"); if($firstdate > $lastdate){ $form->error("First date could not be after the last date."); } } }); The validation works, but: The page will be saved, but it should not because there is an error The error message is not next at the form field. It is only at the top bar. I know that form->error has no relation with the field itself but using fe $form->get("recurringdateend")->error.... doesnt work.
-
Hello @ all, I have studied several posts in this forum (fe. https://processwire.com/talk/topic/969-input-validation-in-back-end-fields/?do=findComment&comment=58931), but I am not able to perform a custom validation of one of my input fields Goal: Check if the date of one field is higher than the other, output an error if the condition doesnt match Here is what I have tried so far: $form->addHookAfter("processInput",function($event) { $form = $event->object; $firstdate = $form->get("date_end");//date field 1 $lastdate = $form->get("recurringdateend");// date field 2 if($firstdate >= $lastdate){ //check if the date of field 1 is higher than the value of field 2 $lastdate->error("Last date must be higher than the first date"); } }); I have tried to insert it in init.php and also in ready.php but without success Has somebody tried to achieve something similar and know how to deal with this situation? Best regards
-
Hook to check if pagetable item should be deleted before save possible?
Juergen replied to Juergen's topic in General Support
Thanks, I have solved this problem now with another way, where I dont need hooking into the pagetable field, but I will take a look at Inputfield::processInput. -
Hello @ all, I have a pagetable field on a page and I want to know if it is possible to check if an item of the pagetable was selected for deletion. As you can see I have clicked the basket icon to delete one item in the pagetable field. What I want to achive is to check fe via a hook before saving the page if an item was activated for deletion, so I can use fe an if/else statement with different code lines. Has anyone done something similar and has an idea how to achive this? Best regards
-
You are right: Combining was the solution - now it works
-
As you can see the children were created with an addHookBefore "saveReady" hook //creation of children $pages->addHookBefore('saveReady', function($event) { $page = $event->arguments[0]; ....some code logic foreach ($periods as $key => $item) { // create new page $k = new Page(); $k->template = 'single-event'; // set template // Copy page fields from parent page to newly created child pages $k->title = $page->title; $k->eventtype = $page->eventtype; $k->eventstatus = $page->eventstatus; $k->participantmaxnumber = $page->participantmaxnumber; $k->eventmaxstatus = $page->eventmaxstatus; $k->notifiable = $page->notifiable; ...... $k->save(); } }); This code works! I have shortened the code because at the beginning there were only some date calculations for recurring events. Then in the ready.php I have tried to store the number of the children in the subdatesnumber field. // Add number of subevents to the subeventnumber field $pages->addHookBefore("saved", function($event) { $page = $event->arguments[0]; if ($page->template == 'events') { if (($page->numChildren) > 0) { $page->subdatesnumber = $page->numChildren; } } });