Course Format Option for disable text box

Course Format Option for disable text box

by Nilesh Pathade -
Number of replies: 2

Hi Moodle Community,


     I am  going to developed New course format plugin. I need simple text box which is default disable. can this possible after selecting my format while creating new course.


I am using like. : 

'location' => array(

                    'type' => PARAM_TEXT,

    ),

/*******************************/

'location' => array(

                    'label' => new lang_string('location', 'format_location'), 

                    'help' => 'location',

                    'help_component' => 'format_classroom',

                    'element_type' => 'text',

              ),


There is  "location" text box which I want set default value and it's should be disable.

Help Me.

Average of ratings: -
In reply to Nilesh Pathade

Re: Course Format Option for disable text box

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is a guess from looking at existing course_format_options() methods, but try this:

'location' => array(
      'label' => new lang_string('location', 'format_location'),
      'help' => 'location',
    'help_component' => 'format_classroom',
      'element_type' => 'text',
'default' => $defaultvalue,
'element_attributes' => ['disabled' => true]
),

Average of ratings: Useful (1)
In reply to Mark Johnson

Re: Course Format Option for disable text box

by Nilesh Pathade -

Thank You Mark for reply.

It's working but just one change. 

'element_attributes' => array('disabled' => 'disabled'),

Thank you once again.  smile