Search the Community

Showing results for tags 'embedding the fields'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Found 1 result

  1. Hi Guys, Here are two issues that took my quite the amount of effort to fix so here im sharing the answers with you. 1. Non-admin user can’t edit profile information using Fredi. I installed Fredi and I sort of got it to work since when logged into Admin i'm able to edit my profile information, when logged in as anyone else however I don't get the "Edit" button. Also showing just certain specified fields doesn't work. When i call Fredi using this syntax and I'm loggedin as Admin it shows me all the editable fields of the user profile, not just "zzp_profiel_naam". $username = $user->name; $another_page = $pages->find("parent=user, name={$username}")->first; echo $fredi->render("zzp_profiel_naam", $another_page); Also I was wondering if it is possible to embed the edit-fields Fredi shows me in a lightbox directly on a page without the lightbox. This would make handeling the updates a lot easier also since it won't have to open the lightbox again on submitting changes, and you won't have to close it again after doing so. SOLVED Instead in using FREDI I used to backend modal to do this, include it like this: <?php $page->setOutputFormatting(true); ?> <iframe src="/cms/profile/?modal=1" style="width:calc(100% - 300px); float:left; border: 2px solid #ccc; padding:0px 0px 0px 0px;" onload="resizeIframe(this)"> </iframe> I used this javascript to change the iframe height to the height of the dynamic content, you could maybe add a onchange listener to resize it every time the height of the content changes. <script language="javascript" type="text/javascript"> function resizeIframe(obj) { obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; } </script> A problem arose when trying to update single image fields, the modal added a second and left the first as it was. To remove the first when uploading a new one to a single image field add this to /site/ready.php // Make sure image upload into single image field deletes old image first $p = $page->process; $t = $page->template->name; if ("ProcessProfile" == $p && "admin" == $t) { $page->addHookBefore('InputfieldImage::fileAdded', function($event) { $u = wire('user'); $i = $u->place_your_image_field_name_here; while ($i->count() > 1) { $i->shift(); } }); } SOLVED Click here for the answer: https://processwire.com/talk/topic/10884-text-area-paragraphs-when-creating-a-page-from-a-form-submission/ 2. Line Breaks from Form Builder textarea not being transferred to the Rich Text Editor on the page it is saved to. What I need is for each textarea inside any form on the site to maintain it's line breaks like submitted by the user when transferred from entries to a page after being checked. The result in the form entries is what is is supposed to be, maintaining the line breaks. When transferred to a page however the breaks don't get transferred end I end up with one large block of non-breaking text. This is what me and some others have concocted to far. The upper part is working and sets a test message in the logs. The bottom one however is not. If I change the method to "saveForm" instead of "savePage" it does give me an error since afterwords I try to call objects that don't exist within the "saveForm" method, so I would assume it's getting called. // This is getting called and sets a test message in the Logs $forms->addHookAfter('FormBuilderProcessor::saveForm', function($event) { $processor = $event->object; $event->log->save('test', 'data=' . print_r($data, true)); $event->log->save('test', 'savePageFields=' . print_r($processor->savePageFields, true)); }); // This is not setting a log file, not even when I transfer the Form entry to a page $forms->addHookBefore('FormBuilderProcessor::savePage', function($event) { $processor = $event->object; $data = $event->arguments(0); foreach($processor->savePageFields as $fieldID => $name) { if(empty($data[$name])) continue; $field = $event->fields->get($fieldID); if(!$field || !$field instanceof FieldtypeTextarea) continue; $data[$name] = "<p>". str_replace("\n\n", "</p><p>", $data[$name]) . "</p>"; $data[$name] = str_replace("\n", "<br />", $data[$name]); $event->log->save('test', 'data=' . print_r($data, true)); $event->log->save('test', 'savePageFields=' . print_r($processor->savePageFields, true)); } $event->arguments(0, $data); }); If you can, please please please! Help me out, im really desperate and have been trying to fix these two problems for ages now Thanks in advance, Bram