I'm having an issue using the parameters of my module to do anything specific. I keep getting the following error from my code:
PHP Fatal error: Call to a member function get() on a non-object
This error occurs in the following file, on line 10:
<?php
echo($params)
class modSystemValidation {
function buildForm() {
$form = '';
$tabIndex = 0;
if($params->get('includeGender','0') == 1 ) {
$form .= '<div id="gender"><input type="radio" name="gender" id="gender_m" value="m" tabindex="' . $tabIndex . '" class="label" /><label for="gender_m">Male</label><input type="radio" name="gender" id="gender_f" value="f" tabindex="' . $tabIndex + 1 . '" /><label for="gender_f"></label></div>';
$tabIndex++;
$tabIndex++;
}
}
return $form
}
modSystemValidation::buildForm();
?>
I've been able to conclude that this is what params echos as to the page with an echo($params):
{"includeFirstName":"1","includeLastName":"1","includeEmail":"1","includePhone":"0","includeAddress1":"0","includeAddress2":"0","includeZip":"0","includeCity":"0","includeState":"0","includeGender":"0","validateFirstName":"0","validateLastName":"0","validateEmail":"0","validatePhone":"0","validateAddress1":"0","validateAddress2":"0","validateZip":"0","validateCity":"0","validateState":"0","validateGender":"0"}
I think my issue is that the $params variable is an array and not an object, but I seem to be having difficulties confirming this with the is_array() and is_object() functions.
A quick overview here before anyone answers this question:
- I know $params is defined
- My issue here is that I need a way to look at $params and do something based off its content.
- While I appreciate the help in structuring my code correctly for Joomla standards, i'd like to hold off on that until I have this issue resolved.
Any help would be greatly appreciated, I'm simply trying to access the params of my module and build form values based off of whether or not the user has enabled that specific field. Right now I know that with the present code the gender field would not be placed on the page, and that is expected. What i'm trying to solve is why I am getting the error on line 10 with the get function. $params is able to be echoed outside the class, but not inside it? Which does not make sense to me, and seems to be where I am getting my issue.