Forums | Mahara Community

Developers /
put two buttons side by side


Noraini's profile picture
Posts: 13

30 October 2017, 7:58 PM

Hi everyone,

i have a question regarding as the subject above. Is it possible to put two button side by side in a form using mahara template?

For example, i want to put button 'BACK' and 'SAVE' in a form. Below is the coding to display the 'SAVE' button:

pieform(array(
    'name'        => 'personalinformation',
    'plugintype'  => 'artefact',
    'pluginname'  => 'resume',
    'jsform'      => true,
    'method'      => 'post',
    'class'       => 'form-group-nested',
    'elements'    => array(
        'studentname' => array(
                    'type' => 'text',
                    'defaultvalue' => param_integer('id'),
                    'title' => get_string('studentname', 'artefact.resume'),
                    'size' => 30,
                    'readonly' => true,
                ),
        'appraisal' => array(
            'type' => 'wysiwyg',
            'rows' => 10,
            'cols' => 50,
            'rules' => array('maxlength' => 65536),
            'title' => get_string('appraisal', 'artefact.resume'),
        ),
        'save' => array(
            'type' => 'submit',
            'value' => get_string('save'),
            'class' => 'btn-primary'
        ),  
    ),
));

 

Really appreciate if someone can help me. Thank you..:)

Robert Lyon's profile picture
Posts: 346

31 October 2017, 7:53 AM

Hi Noraini

You just need to replace your 'submit' button with a 'submitcancel' one, so you just need to change this bit:

       'save' => array(
            'type' => 'submit',
            'value' => get_string('save'),
            'class' => 'btn-primary'
        ),

to this:

        'save' => array(
            'type'  => 'submitcancel',
            'value' => array(get_string('save'), get_string('back')),
            'goto'  => get_config('wwwroot') . 'path/to/return/to.php',
         ),

 

Cheers

Robert

Noraini's profile picture
Posts: 13

31 October 2017, 5:55 PM

Thanks Robert!

That solved my problems. Really appreciate it..:)

Kristina Hoeppner's profile picture
Posts: 3369

31 October 2017, 8:33 AM

Hello Noraini,

And if you are looking for the correct styling of your buttons, you can check out the style guide. You can reach it by going to wwwroot/theme/styleguide.php It contains the majority of our available styles. There are a few buttons that will need to be added.

Cheers

Kristina

 

Noraini's profile picture
Posts: 13

31 October 2017, 5:58 PM

Thanks Kristina for the reply.. :)

5 results