element validation

loudy

Member
Hello,

I have tried to following this post: http://fabrikar.com/forums/index.php?threads/compare-2-fields-for-validation.10762/
but I was not able to do what I need.

I have a form with 2 elements:

1) joindata: with joomla user table: ID
2) Student ID confirmation box.


vald.png

I created a php validation in the seudent id elements and add the following:

$StudentID = JRequest::getVar('xesefc_users___mto___StudentID');
$MTO = JRequest::getVar('mto_users___mto___MTO');
return $StudentID == $MTO;

So I'm not sure, how to validate that the second box need have the same number from the box1.

Or if there is any way to auto fill the box 2.
so if I select or type anything in the box 1, the box 2 will be auto fill and read only so no one can change the input in the box 2?

Please help.
 
You shouldn't use JRequest, it's deprecated (the thread is about Fabrik2).

Do you really have 3 underscores inside an element name? Not sure if this will break anything because ___ is used as delimiter between table and element/column name.

If you want to compare ids you should use element_raw (element will contain labels).
Or if there is any way to auto fill the box 2.
so if I select or type anything in the box 1, the box 2 will be auto fill and read only so no one can change the input in the box 2?
Use a calculation element.
 
Definitely don't use ___ in an element name, and I would advise changing it. I thought we actually had some code to disallow that. I'll check.

-- hugh
 
Hello, about the ___
Actually it auto generated, when I created the list.
see here:
mmm3.PNG

So not sure, do I need to change all that.

as I see the ___ in all my other lists. and all of them are generated when I created the list or when I add an element.

Please advise.
 
Hi, how I can use the element_raw, I did some research and I could not find any help tips.

Thanks,
 
Actually it auto generated, when I created the list.
Yes, this is the complete element name, your database table is mto, the short element name/column name is studentID.
So your JRequest::getVar('xesefc_users___mto___StudentID'); is complete wrong, it must have been
JRequest::getVar('mto___StudentID'); resp. JRequest::getVar('mto___StudentID_raw');

But instead of JRequest use
$app= JFactory::getApplication();
$ids=$app->input->get('mto___StudentID','');
 
Hi I have added the code to the php validation in the element validations section.
code.png

not sure its not working in the site.
 
No, this was only an example how to replace JRequest, in your case

$app= JFactory::getApplication();
$StudentID=$app->input->get('mto___StudentID_raw','');

+ the rest of your code
 
Hi, not sure about the rest of the code, I have added the code
$app= JFactory::getApplication();
$StudentID=$app->input->get('mto___StudentID_raw','');

to a php validation but still not working, I think I just give up :)

Thank you for the help anyway.
 
This code is about Lavarel, not Joomla.
Try
Code:
$app= JFactory::getApplication();
$StudentID=$app->input->get('mto___StudentID_raw','');
$MTO = $app->input->get('mto___MTO_raw','');
return $StudentID == $MTO;
 
Hi, thank you for the help, I really do not know the difference, but I really have interest to learn the code, any suggest for a good source that can help me. Thank you so much again.

For the code, I have enter it in the php validation in the MTO element. see my setting:
vald.PNG

The I removed it and enter it in the StudentID element php validation, nothing worked. :(
 
For debugging add var_dump();exit;
Code:
$app= JFactory::getApplication();
$StudentID=$app->input->get('mto___StudentID_raw','');
$MTO = $app->input->get('mto___MTO_raw','');
var_dump($StudentID,$MTO);exit;
return $StudentID == $MTO;
In any case you must use your correct full element names (+ appeding _raw), I don't know if mto___StudentID is correct, only got it from your posts.
In your refugees site there none of these elements or table/list names.
 
Hi, thank you for the help,
now I'm getting: array(1) { [0]=> string(3) "404" } string(3) "404"
when I try to add data, I have added the site info under my sites for your to look.

Please guide.

Thank you so much again.
 
Getting the same issue: array(1) { [0]=> string(3) "404" } string(3) "404"

Not sure how to fix this.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top