Help with form

Hi,

I am working on a registration form that is to be used for recruitment purposes.
I will appreciate any tip on how to implement a structure like the following:

Nationality (if British, submit form)​
*if not British ?we should ask the following question:
Do you have a work permit or visa entry clearance giving you right to work?​
Yes ? No​
If No ? we cannot register
If Yes - Register!
My initial thoughts were to implement this with a cascading drop down but I ran into a wall on what to do to implement the conditions.

Please help.

Many thanks in advance.

Essay
 
hello

So first you would need two elements - lets say the nationality one is a dropdown with values such as 'british, french" etc with a full element name of 'registration___nationality'
You also have a yesno element for the work permit question.

You should edit the nationality element and under the javascript tab, create 3 events:

Code:
action: load
hide: element/yesno  'when this' == 'british'
 
action change:
hide: element/yesno  'when this' == 'british'
 
action: change
show: element/yesno  'when this' != 'british'

Next you want to add 'isnot' validation to the yesno element.:

Is not: 0

This will fail the form is the value is 0

Obviously you need to take into account that the yesno element should still pass its validation if you have 'british' selected so you need to add a 'condition' to the validation:

PHP:
return $_POST['registration___nationality'][0] != 'british';

This compares the selected value for the 'registration___nationality' element, and if it is NOT 'british' returns true, meaning the validation should occur. If it IS british then the form skips over this validation rule.
 
Hi Rob,

Many thanks for the detailed explanation as usual. I really appreciate it.
I will revert to you today on this.

In the meantime, is it possible to join or move your response to this post to Fabrik 3.0.x for Joomla 2.5.x? I mistakenly posted my question here but it really should have been on the other board where I then re-posted the same question.

Once again, thank you for the great efforts you put into Fabrik form.
 
Hi,

Thanks for the help so far.
I have gone further by creating other form fields and they work as expected.
I am using the JUser plugin on the form to create users. However, I need a hidden field in the form to input a default role into another table in the database that has something like: (uid,role,dated) but I can't get it to work.

Please help.

regards,
Essay
 
Hi
To insert another record in a separate table, you should use the upsert form plugin - which is only currently available from the github repository.
 
Thanks Rob,

The table I need to input the data into is not a Fabrik table or list. It is another component that needs the usergroups defined based on the registration form made in Fabrik.

Is there a way to do this. I have tried the php plugin but no luck.

My lines for the php plugin looks like this.

Code:
function onUserAfterSave($user, $isnew, $success, $msg){
            if( $isnew ){
                if(isset($_POST['userrole'])){
                    $db = &JFactory::getDBO();
                    $created = date('Y-m-d H:i:s');
                    $query = "INSERT INTO #__js_job_userroles (uid,role,dated) VALUES (".$user['id'].", ".$_POST['userrole'].", '".$created."')";
                    $db->setQuery( $query );
                    $db->query();
                    //user group query
                    if($_POST['userrole'] == 1) $groupid = 10;//employer
                    else $groupid = 9; //jobseeker
                   
                    $query = "INSERT INTO #__user_usergroup_map (user_id,group_id) VALUES (".$user['id'].",".$groupid.")";
                    $db->setQuery($query);
                    $db->query();
                    $componentAdminPath = JPATH_ADMINISTRATOR . '/components/com_jsjobs';
                    $componentPath =  'components/com_jsjobs';
                    require_once $componentPath . '/models/jsjobs.php';
                    $config = array( 'table_path' => $componentAdminPath . '/tables');
                    $model = new JSJobsModelJsjobs($config);
                    $result = $model->assignDefaultPackage($_POST['userrole'],$user['id']);
                }
            }
        }

Essay
 
if you are using the Fabrik PHP plugin then you would select it to run onAfterProcess, and simply place the code you want in the selected PHP file, it should not be wrapped in a onUserAfterSave function - which I think is specific to Joomla User plugins.
 
Hi Rob,

I just can never thank you enough for what you do.
I have just stumbled upon a response by Hugh on another post and realised that since I was trying to INSERT from my custom form submission, I should have something like "$userid = $formModel->getElementData" in the PHP.
I edited it, tested it, went to check activation mail and saw that you have responded.

Thanks so much.

This is resolved but I am still working on the form and will keep you posted.

Regards,
Essay
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top