Jump to content

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

Looks like we have a working solution to Bram's FormBuilder issue.

  • Like 8

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By benbyf
      I have a a form in my site footer that can be accessed anywhere on site, I've added the form in the _inc.php file and added the render in the pages footer.php. However, this works well on the homepage e.g. you can submit said form and get a thank you on reload, doesnt work at all on other pages... Just lots like a fresh reload. Any thing im doing wrong here or ways to diagnose as there isn't an error log for formbuilder etc...?
    • By prestoav
      Hi all and thanks for the great work on PW!

      One thing I find I have to do on any new site is add the Justify plugin to textarea fields as it is such a widely required feature for text headings in content.

      ANy chance this could be added to the core an automatically be installed on new textarea fields using CKEditor?

      Thank you!
    • By neophron
      Hi,
      I hope, this is the right place for questions about the Formbuilder (I couldn't find in the ProField support a subsection for the Formbuilder).
      A client needs for his website a random generator of a code (as winning numbers). This generator should be placed in a simple form (name and email) and a random generated code should be visible there.
      This code, or winning number, must be stored in the db together with the name and email. And the participant must receive a confirmation email with this code.
      I know, that the Formbuilder can store and send data to the user. But what about a random generated code? Is this a hook job?
      I found this module: http://modules.processwire.com/modules/process-field-generator/ but it's not for PW 3. 
    • By prestoav
      Hi folks.
      I'm building a Formbuilder form to create new advert pages in a marketplace. Formbuilder is ideal for this. I need to add a description field that allows text to be added with line breaks etc. so showing a CKEditor field would be ideal (i.e. exactly like the field I'm typing into right now)!.
      Does anyone know if it's possible to add a CKEditor field to the front end presentation fo a Formbuilder field, maybe via a module or such?
      Many thanks!
    • By Peter Knight
      I have a few web forms which require testing on a weekly basis and I don't want the recipients (administrators) to receive these test emails.
      What would be a good way to test approx 15 forms from the front end and have the test delivered a list of secondary administrator recipients?
      I'm thinking that I could have some kind of config file which watches for a trigger word or email and then understands that it's a test and to bypass the normal admins?
      All of the forms ask for an email address so I could setup an email such as 'testform@email.not' etc which my config file (hook?) would watch for.
      Or is there a better way to do this?
      Additionally, I have a few extra requirements...
      Forms should goto an alternative success page. This is because I don't want my test to skew my Google Analytics conversion tracking Forms would need to be tested from the front-end and not the PW admin area Any advice appreciated.
      BTW I realise this should be posted in the proper FormBuilder support forum. I am in the process of renewing my license for access to that support forum.
       
×
×
  • Create New...