Recommended Posts

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

Share this post


Link to post
Share on other sites

@Bram,

Are either of these issues solved yet?

Nope, not yet! Do you think you can help? We can continue this in PM's if you like :)

Share this post


Link to post
Share on other sites

Bram, I've sent you a PM.

I can certainly take a look at your first issue. I've no experience of fredi - so I'll pass on that one, for now.

Regards,

Steve

Share this post


Link to post
Share on other sites

1. 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); 
});

As a courtesy, if anyone solves this issue, please post to the original post in the Form Builder VIP Forum where @bramwolf has already brought this up.  BTW, I believe this was actively being worked on by @Ryan and was only awaiting a response from @bramwolf.

https://processwire.com/talk/topic/10884-text-area-paragraphs-when-creating-a-page-from-a-form-submission/#entry117794

Thanks

Share this post


Link to post
Share on other sites

Sure thing!

I actually already replied Ryans last post with new input but frankly, im on a very very tight lease here and I need this figured out as soon as possible,

so I called in all the help I could get. I meant no disrespect or ungratefulness whatsoever. I'll make sure the answer makes it to that post as well :)

Bram

Share this post


Link to post
Share on other sites

As a courtesy, if anyone solves this issue, please post to the original post in the Form Builder VIP Forum where @bramwolf has already brought this up.  BTW, I believe this was actively being worked on by @Ryan and was only awaiting a response from @bramwolf.

https://processwire.com/talk/topic/10884-text-area-paragraphs-when-creating-a-page-from-a-form-submission/#entry117794

Thanks

can help you but rates is little higher 

Please contact me at S k y p e: cis(dot)ian 

Regards 

ian

Share this post


Link to post
Share on other sites

Hi Ian,

Thanks for the offer, but I think we have second point figured out as well, I will post updates on a solution when I finalized it.

Gr,

Bram

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Barry
      I'm trying to write a value to a textarea via de API. I'm making use of the Multivalue Textformatter module which works great for when the field has multiple rows added via admin.
      But now I'm trying to add multiple lines to the textarea via the API and I cannot for the life of me figure, or find out how to do this.
      I'm adding
      "&#13;&#10;" to the end of of each new line. When I apply this value to a textarea in the template, this works fine, but when I
      $line = "this is a line"; $p->textarea = $line."&#13;&#10;" I just get "this is a line &#13;&#10;". This is the case with the "/n" and "<br>" as well.
      Turning on tinyMC doesn't help either as the output in the template is still the same. Turning on the HTML Encoder doesn't help either.
    • By GeekMan
      When I create a form with FormBuilder, is there a way to stop it from showing the vertical scroll bar on the right side of the form page??? For example look at this page.
      http://www.cji.edu/registration/reg-lemd/?course_name=Effective Report Writing&course_date=December 6, 2017
      Why does it even have a scroll bar?
    • By cosmicsafari
      Hi all,
      A few of our clients are having issues receiving emails sent via form builder after a client submits a form.
      They display fine in certain clients but in Outlook especially the body content is either missing or the raw code is displayed.
      Does anybody have any ideas why this might be the case or any ideas about how to diagnose the issue?
      Not sure if this is an issue with the emails themselves or the server from which they are being sent.
      Just wondering if anyone else has experienced anything similar?
    • By AndySh
      Hello!
      I need your assistance please. I purchased the module FormBuilder. Unfortunately, the module discontinued delivering customer submissions to e-mail box specified in the module settings. Direct mailing to the e-mail box works OK. The module settings stays the same and are correct, like "Send e-mail to administrator(s) is checked. The last version of FormBuilder 3.0 has been installed. Please advise how to resolve the issue becase I cannot get orders from customers anymore (((
    • By neonwired
      Formbuilder isn't redirecting either using the path or the page ID, it just prints them as a message.