Jump to content

Module: FormHelper


pwFoo

Recommended Posts

This is spooky. Just tried reinstalling the module, and no change. I had installed it today for the first time, so I was using the latest version.

In my case I don't even get the submit button.

Other tests I've made:

  • generating pages with other templates
  • by page instead of template
  • tried leaving incognito mode in chrome (I needed two logged users)
  • added superuser role
  • EDIT: tried array example from the documentation, discovered an extra ) near the end that causes an error, but even fixing that, no cigar
  • EDIT 2: tested on a previous site with PW 2.5.3

Nothing seems to work.

Could it be something to do with XAMPP's default PHP settings?

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...
  • 1 month later...

Done a short compatibility test to PW 3.0 dev and it seems to work with a minimal change because of php namespace to get it work by the PW 3.0 module compiler.

File: FormHelper.module

Replace all "hookEvent $event" with "$event"

Maybe I'll optimize my modules for the PW3.0dev usage soon.

Link to comment
Share on other sites

  • 4 months later...

Hi Robguy,

sorry because of my late response!

Quick test uninstall / install FormHelperExtra (version 0.3.1) without errors. 

Could you provide more details about your setup (PW version, PHP version, ...)?

Hi, i have the same issue 

 Session: Unable to install module 'FormHelperExtra': SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fhStorage' for key 'name'

this happend on my second attempt to install FormHelperExtra. On the first atempt i got the following error: "Unable to install module 'FormHelperExtra': Can't save page 0: /fhstorage/: It has no parent assigned"

PW Version: 2.7.2

Php Version: 5.5.9

Here's the phpinfo() output of my localmachine where it happend (i just changed the project name)

http://jsbin.com/yatexeguku/edit?output

for "fhStorage" search, i have this entries in my database:

post-620-0-20200800-1461655219_thumb.jpg

PS:

i just have tried to guess what's wrong. i have not build any processwire module untill yet, but might it be possible that you whant to request the admin page, to create the fhStorage page, but it's not requestable with get('/admin') ? becouse my admin page has the name "processwire":

post-620-0-98906900-1461656602_thumb.jpg

  • Like 1
Link to comment
Share on other sites

Hi, i have the same issue 

 Session: Unable to install module 'FormHelperExtra': SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fhStorage' for key 'name'

this happend on my second attempt to install FormHelperExtra. On the first atempt i got the following error: "Unable to install module 'FormHelperExtra': Can't save page 0: /fhstorage/: It has no parent assigned"

Just struck this also. @Chris is right about the source of the problem...

$storage->parent = $this->pages->get('/admin/');

...should instead be...

$storage->parent = $this->pages->get(2);

Making the change above does allow the module to be installed but first you have to delete the fhStorage template from the failed installation attempt. And this isn't straightforward because the system flag is set, and can only be removed via the API. To do this...

$t = $templates->get("fhStorage");
$t->flags = Template::flagSystemOverride;
$t->flags = 0;
$t->save();

Then the template may be deleted via the Admin (or the API).

  • Like 2
Link to comment
Share on other sites

Hi Chris,

Hi Robin,

You're right, I used "/admin" and it will fail with another backend path...

I replaced '/admin/' with the pid 2 without testing and pushed a new release. So should be fixed in 0.8.6.

Sorry for delay, but I'm busy with other things at the moment. I hope I'll back soon...

Thanks!

Link to comment
Share on other sites

  • 1 month later...

Hi pwFoo,

like i wrote in the FrontendUser Thread - your modules are a pleasure to use...;)

one questions on form building...if i create a form from an array it is clear to set the field sanatizer.

The question is if i use a form created from a template - have i to set the sanatizer for every field, too- or use the module the sanatizer for the specific field like (PW text field...PW integer field...)?

regards mr-fan

Link to comment
Share on other sites

It was planned to set a a sanitizer that makes sense by default, but that isn't implemented because I don't know all the field / inputfields attributes and types to find out which should be the correct sanitizer.

At the moment I follow the pw blog about new 3.0 features (frontend editing, ...) and will update / optimize the modules for 3.0. I hope there will be some more nice new features which could simplify my modules ;)

Link to comment
Share on other sites

Ok it was just a question to confirm my readings of your sourcecode...;)

For now i like to go the simple route and set the sanatizer if i get a value like in your docs described:

    // Get sanitized value with changed sanitizer
    $form->fhValue($fieldname, 'text');

for additional validation i just use simple additional functions - just what i need:

http://www.maheshchari.com/60-validation-functions-with-php-2-part/#function_rangevalue

Thank you for your answer and as information i use your modules on 3.0.18 without problems!

Best regards mr-fan



			
		
  • Like 1
Link to comment
Share on other sites

Another question on this...if i setup some fields from a template like the user template.

And i wanna set a field of this form required....i tried this like in forms from API:

$form->get("pass")->label = "Change Password?";  //works
$form->get("pass")->required = true;   //works not

How could i achive this or is there something missing in the FormHelper?

Edit: All is working perfect....it just sets the CSS class to required not the $form input handling so i've to check manually this special fields...;)

Best regards mr-fan

Link to comment
Share on other sites

Thank you for your hint...but i'm a just a poor spare time programmer...so very often in the late evening i don't get things sorted right :blush:

It happens often that if i hit the "Post" button i change my mind and get the solution by my self.... :ph34r:

$form->get("somefield")->required = true;
// add only CSS class required to the field so simple get the "*"  - NOT change the form processing/handling like
// you set the field to required in the admin>field>settings!!

Basic problem was the pass (password) field from the user template....in the admin i don't wanna change it to be required so i have to fill in on every change of the other user fields....and i have frontend forms to edit users profile...so on this frontend stuff i have to check for this field myself on processing and all is good.

// get the input values for processing
$email = $form->fhValue("email", "email");
$password = $form->fhValue("pass", "text");

// check for email duplication
if (email_valid($email) == true) {
    // email exists
    $out .= message("email exists","danger");
} elseif ($password == ''){
    // no password is there
    $out .= message("forgot to enter password","danger");
} else {
//...
// all is there so go process form

Best regards mr-fan

BTW i can't say it too often - your modules for Forms are really really great - have you known that the FormHelper Module even renders MapMarker Fields on frontend....usable!!

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

A Question that is Hook related...since i'm not so familiar with hooks...

I have a form from template "Entry" with some adress fields....and a checkbox for the creator of an entry to use his default adress in the entry...so the question is

where or how i have to hook to change some values/fields depending on a checkbox...since all fields are set required.

I need a hook before processing the form to check if the checkbox == 1 to set the needed adressfield values to the default values from the $user...than process the form inputs...don't know how to start. I've read your example hooks on bitbucket and tried some things but without luck.

Best Regards mr-fan

Link to comment
Share on other sites

In the plugin example to login with nickname / email address I addHookBefore auth() and change / validate form values. Or set field validation to error if your check fails. Something like that?

 

You can also hook before / after " form api processInput" method.

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...
  • 1 year later...

Is this module still active? 

I like the idea how easily you can implement an existing form on a page.

I tried to use it with pw3 in a module (including the extra part) to put in an admin page 

	public function ___executeadd() {
$fh = $this->$modules->get('FormHelper');
$form = $fh->create($templates->get('news'));
echo $form->render();

	}

but i get an error ?

 Method ProcessWire::get does not exist or is not callable in this context

Link to comment
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
×
×
  • Create New...