jh_captcha throws "Validation failed while trying to call showAction" - typo3

I've implemented jh_captcha into my extension as descripted in the documentation:
https://docs.typo3.org/typo3cms/extensions/jh_captcha/Developer/Index.html#add-the-captcha-to-your-domain-model
It's working create within Actions like New, Edit or List. But I get the following error as soon showAction is called:
Validation failed while trying to call showAction
As soon as I remove NotEmpty from the validation the showActions are working, but New and Edit obviously not.

Possibly the validation fails on subobjects. There is also a solution to remove or change Validators inside the initializeXY Actions. Heres a german blog post about this topic: http://blog.teamgeist-medien.de/2016/02/typo3-extbase-validierung-von-unterobjekten-deaktivieren.html

You can add the annotation #dontvalidate $param on your showAction so the validation is not proceeded.

Related

How to get the form validation status in "react-validation", when submitting the form?

I'm trying to use react-validation for simple form validation in React. I understood how to validate the fields according to my needs, but what i do not understand, is how to get the "status" of the form, when the user tries to submit the it.
The documentation says that the Form component provides 4 public methods:
validate(name), validateAll(), showError(component [,error]), hideError(component)
From what i understand, these methods are accessible by a ref to the Form component:
<Form ref={c => { this.form = c }} onSubmit={this.handleSubmit.bind(this)}>
When i console log this.form in my submit handler, i do get an object with the above mentioned methods, but when i call one of them, like validateAll(), it returns undefined. I do not understand why.
Can someone help me with this specific plugin, or perhaps recommend a different simple alternative? I need to perform very basic validation(but can't use HTML built in one), and do not need something fancy like react-form or redux-form(i do not even use Redux in this project)
I have checked it in sandbox, please review it,
and I can tall you that it DOES work in this way. When you call this.form.validateAll() it returns undefined BUT it executes all validation functions and appends to form error messages defined in that functions. So may be it is even unnecessary validateAll to return smth
The solution I have found to provide state.isValid. Set isValid = true on form change
handleChange() {
this.setState({ isValid: true });
}
and in each validator set state.isValid = false if validation is not pass

Apigility content validator - enable to fetch service validator

I was following the tutorials on https://apigility.org/documentation/content-validation/basic-usage. But, when I tried to inject the input filter service AddressBook\V1\Rest\Contact\Validator in the ContactResource, I get the following error:
Zend\ServiceManager\Exception\ServiceNotFoundException
File:
/Users/.../src/apigility-tutorials/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529
Message:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for AddressBook\V1\Rest\Contact\Validator
I am not sure if it's an issue with apigility itself, this is why i'm asking if the example shown in the link above actually works when using dependency injection. Thanks
Got it. According to the zf-content-validation doc, the input filter is registered through Zend\InputFilter\InputFilterPluginManager which means I have to get the InputFilterManager service first then get the Contact input filter service as follows:
$inputFilter =
$serviceLocator->get('InputFilterManager')
->get('AddressBook\V1\Rest\Contact\Validator');
Thanks for looking into it.

Call to undefined function bp_core_get_user_email() - Buddypress issue

I am having a issue where I am trying to retrieve the email of the user who is logged in using Buddypress. Here is my code:
global $bp;
echo bp_core_get_user_email($bp->loggedin_user->id);
Here is the error message that pops up when I open the php page:
"Fatal error: Call to undefined function bp_core_get_user_email() in /home/user/public_html/useremail.php on line 4"
Have you loaded WordPress & BuddyPress in your file useremail.php?
I see that it's the same level as wp-config.php. To make it know anything about WP/BP functions you need to do at least this:
include ('./wp-load.php');
Otherwise in your situation that php file will through errors everytime you will use non-standard php functions.
But the true way is to use WP - create:
1) a plugin that will handle all requests to a specific url
OR
2) create a page in WP dahsboard with a specific page template, and in its template file you can write whatever code you need or want.
Other option to get the email:
$user_active = wp_get_current_user();
$user_mail = $user_active->user_email;

Zend_Controller_Action_Exception not showing a 404 page

I'm trying to get Zend to throw a 404 error if an array contains less than 10 elements, but it is currently just sending me a generic "Error" page. I know the 404 exception is configured properly as they work elsewhere in the site so it must be a problem with my parameters or something...
I've tried formatting this several different ways and I've checked the Zend API to make sure the parameters I'm passing are OK and they seem to be correct, but I must be doing something wrong.
My code is currently as follows:
$properties = array(1,2,3,4,5,6,7,8,9)
if (count($properties) < 10){
throw new Zend_Controller_Action_Exception('Page does not exist.', 404);
}
$this->view->rows = $properties;
$this->callRender();
Thanks for your time.
Check out the ErrorHandler plugin docs and how it works within the MVC. You'll notice that by default the errorHandler works as postDispatch() plugin. The activity you are trying describe as '404' is completely outside of the dispatch loop so it is handled as any other program error.
I don't have any code for you but I'm pretty sure you can find a usable answer in these 2 references.

How can I check my post data in Zend?

I am a beginner and I am creating some forms to be posted into MySQL using Zend, and I am in the process of debugging but I don't really know how to debug anything using Zend. I want to submit the form and see if my custom forms are concatenating the data properly before it goes into MySQL, so I want to catch the post data to see a few things. How can I do this?
The Default route for zend framework application looks like the following
http://www.name.tld/$controller/$action/$param1/$value1/.../$paramX/$valueX
So all $_GET-Parameters simply get contenated onto the url in the above manner /param/value
Let's say you are within IndexController and indexAction() in here you call a form. Now there's possible two things happening:
You do not define a Form-Action, then you will send the form back to IndexController:indexAction()
You define a Form action via $form->setAction('/index/process') in that case you would end up at IndexController:processAction()
The way to access the Params is already defined above. Whereas $this->_getParam() equals $this->getRequest()->getParam() and $this->_getAllParams() equals $this->getRequest->getParams()
The right way yo check data of Zend Stuff is using Zend_Debug as #vascowhite has pointed out. If you want to see the final Query-String (in case you're manually building queries), then you can simply put in the insert variable into Zend_Debug::dump()
you can use $this->_getAllParams();.
For example: var_dump($this->_getAllParams()); die; will output all the parameters ZF received and halt the execution of the script. To be used in your receiving Action.
Also, $this->_getParam("param name"); will get a specific parameter from the request.
The easiest way to check variables in Zend Framework is to use Zend_Debug::dump($variable); so you can do this:-
Zend_Debug::dump($_POST);
Zend framework is built on the top of the PHP . so you can use var_dump($_POST) to check the post variables.
ZF has provided its own functions to get all the post variables.. Zend_Debug::dump($this->getRequest()->getPost())
or specifically for one variable.. you can use Zend_Debug::dump($this->getRequest()->getPost($key))
You can check post data by using zend
$request->isPost()
and for retrieving post data
$request->getPost()
For example
if ($request->isPost()) {
$postData = $request->getPost();
Zend_Debug::dump($postData );
}