-
Posts
1,306 -
Joined
-
Last visited
-
Days Won
13
Everything posted by Juergen
-
I guess the difference is that this works on standard frontend templates but not on user templates.
-
No, this returns the same error message. I have tried it before. If I output (echo) $upload_path . $files[0] it will be outputted correctly, so I dont understand the error message because it is a string.
-
I have also tried to make an image upload for an user image on the frontend: VARIABLES $user->userimage = PW form field that stores the user image userimage = name attribute of the formfield for the userimage on frontend //create userimage conditions $upload_path = $config->paths->assets . 'files/avatar_uploads/'; $f = new WireUpload('userimage'); $f->setMaxFiles(1); $f->setDestinationPath($upload_path); $f->setValidExtensions(array( 'jpg', 'jpeg', 'gif', 'png', )); //ERROR HANDLING $files = $f->execute(); if ($f->getErrors()) { $userimageclass = ' uk-form-danger'; foreach($f->getErrors() as $key=>$error) { $errors['imageerror'. $key] = $error; $imageerrormessage .= ukformhelpblockdanger($errors['imageerror'. $key]); } foreach($files as $filename) unlink($upload_path . $filename); } else { $userimageclass = ' uk-form-success'; } if ($files) { $user->userimage->removeAll(); // wirearray - remove all older images first $user->userimage = $upload_path . $files[0]; // store the new userimage -> THIS LINE CAUSES THE ERROR MESSAGE } The upload to the temp folder works but this line of code leads to an error message: $user->userimage = $upload_path . $files[0]; // store the new userimage -> THIS LINE CAUSES THE ERROR MESSAGE The settings for the image field is max-number = 1 and automatic. The image will be fetched properly: Maybe the problem is that the page is a user page and not a default frontend page. Can anyone help me out? Best regards
-
Or you can use AdminOnSteroids which has this function integrated.
-
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:
- 28 replies
-
- 1
-
- icon
- fontawesome
-
(and 2 more)
Tagged with:
-
- 28 replies
-
- icon
- fontawesome
-
(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.
-
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