Forums | Mahara Community

Developers /
Cannot set field type to radio button


Noraini's profile picture
Posts: 13

12 October 2017, 19:26

Hello. I'm new in develope code using mahara.

I want  to ask if my code like this. how to set type radio button?

i call field from function located artefact/internal/index.php :

$element_list = ArtefactTypeProfile::get_all_fields();

Then in the function located at artefacts/internal/lib.php :

$out = array(
            'firstname'       => 'text',
            'lastname'        => 'text',
            'studentid'       => 'text',
            'preferredname'   => 'text',
            'introduction'    => 'wysiwyg',
            'email'           => 'emaillist',
            'officialwebsite' => 'text',
            'personalwebsite' => 'text',
            'blogaddress'     => 'text',
            'address'         => 'textarea',
            'town'            => 'text',
            'city'            => 'text',
            'country'         => 'select',
            'homenumber'      => 'text',
            'businessnumber'  => 'text',
            'mobilenumber'    => 'text',
            'faxnumber'       => 'text',
            'occupation'      => 'text',
            'industry'        => 'text',
            'maildisabled'    => 'html',
            'phylosophy'      => 'text',
            'vision'          => 'text',
            'mission'         => 'text',
            'job_interest'    => 'textarea',
            'age'             => 'text',
            'gender'          => 'radio',
        );

 

If i set gender type like above, error 'A nonrecoverable error occurred. This probably means you have encountered a bug in the system ' display.

Cecilia Vela's profile picture
Posts: 110

13 October 2017, 12:38

Hi Noraini,

The error message that you get is a generic one, you can try to set the "production mode" to false, so we can get more information about the exact place where it is failing.

For that you need to change the following value in the config.php file under htdocs/ directory:  

$cfg->productionmode = false;

This way, when you try to access the page that is failing, you will see the error logs on the same page and hopefully it will display an error message with the exact place in the code where the exception is generated.

Please let us know if you need more help with this.

Regards,

Cecilia

Noraini's profile picture
Posts: 13

13 October 2017, 17:19

Hi Cecilia, Thanks for the respond. Here is the error that display:

 

[WAR] 3a (lib/errors.php:536) [PieformException]: Radio elements should have at least one option
Call stack (most recent first):
  • exception(object(PieformException)) at Unknown:0

I dont know how to add the option into my coding like below:

$out = array(
            'firstname'       => 'text',
            'lastname'        => 'text',
            'studentid'       => 'text',
            'preferredname'   => 'text',
            'introduction'    => 'wysiwyg',
            'email'           => 'emaillist',
            'officialwebsite' => 'text',
            'personalwebsite' => 'text',
            'blogaddress'     => 'text',
            'address'         => 'textarea',
            'town'            => 'text',
            'city'            => 'text',
            'country'         => 'select',
            'homenumber'      => 'text',
            'businessnumber'  => 'text',
            'mobilenumber'    => 'text',
            'faxnumber'       => 'text',
            'occupation'      => 'text',
            'industry'        => 'text',
            'maildisabled'    => 'html',
            'phylosophy'      => 'text',
            'vision'          => 'text',
            'mission'         => 'text',
            'job_interest'    => 'textarea',
            'age'             => 'text',
            'gender'          => 'radio',
        );

 

Really appreciate if you can help me. Thank you.

31 October 2017, 17:41

Hello Noraini,

It is correct that you added the 'gender' line in the $out array, but you still have to define the details of the 'radio' element in the file /artefact/intenal/index.php. There you will find the code that defines the details for each of the elements that are shown in the Profile screen.

Please check this page on the wiki, it might help when you are working with Pieforms.

Regards,

Cecilia

Noraini's profile picture
Posts: 13

01 November 2017, 13:41

Thanks Cecilia for the reply.

My problem solved as i add below code in index.php file :

 

if ($element == 'gender') {
    $items[$element]['options'] = array('male' => 'Male','female' => 'Female');
    $items[$element]['defaultvalue'] = get_config('gender');
}

 

Thank you,

Noraini

 

5 results