These are chat archives for COCOPi/cockpit

3rd
Sep 2015
Julian Renard
@julianfox
Sep 03 2015 13:28
Hey, for validate required field in form, i just need to add "required" to input bailse... right ? I just did it and that don't work, I've forgot something ?
Florian Letsch
@florianletsch
Sep 03 2015 13:35
what is "bailse"?
Julian Renard
@julianfox
Sep 03 2015 13:37
Sorry, i mean input tag <input required/>
Matthijs Alles
@malles
Sep 03 2015 13:46
@julianfox That will activate the browsers own HTML5 form validation. It will prevent a form from submitting, but you will rely on the browser, and should check for input serverside as well
Julian Renard
@julianfox
Sep 03 2015 14:04
ok, so i have to check even the required field in my custom form validation like this example: http://getcockpit.com/docs#!modules/forms ?
I thought that Cockpit scan the html form tag for generate a default form validation
Matthijs Alles
@malles
Sep 03 2015 14:12
I'm not sure about that, it might well be yeah
arlg
@arlg
Sep 03 2015 14:17
Hi, I have a problem with Cockpit Form. It works locally but not on my server. I get a 500 error when the data sends. I have the same files and configuration. What could happen ? I save the data in the admin.
Julian Renard
@julianfox
Sep 03 2015 14:55
I just checked the cockpit code... apparently there are no default validation...
Matthijs Alles
@malles
Sep 03 2015 14:56
okay, well you can use the browser for it. Serverside validation can be done with a file named formname.php in the custom folder
Julian Renard
@julianfox
Sep 03 2015 15:03
Yes i did it... so i use:
if (empty($app->param('form/name')) { return false; }
for each field, but that don't work
my form is not valid even if all field are full
Matthijs Alles
@malles
Sep 03 2015 15:16
and if you just only return false there? To see if the file is working?
the fields should be present as $app->param('email'), just the field-name
File should be /custom/form/Formname.php
Julian Renard
@julianfox
Sep 03 2015 15:32

ok so sorry it's my bad... my prev code is wrong

the correct one is:
if (empty($app->param('form/name'))) { return false; }

That work like it :-)

I tested without 'form/' and that don't work, i use the master version...
I concluded that there is no default form validation.

Thanks for your help @malles :+1: