@@ -51,11 +51,13 @@ public function definition() {
5151 // Fill in the data depending on page params later using set_data.
5252 $ modform ->addElement ('header ' , 'general ' , '' );
5353
54- // The subject.
55- $ modform ->addElement ('text ' , 'subject ' , get_string ('subject ' , 'moodleoverflow ' ), 'size="48" ' );
56- $ modform ->setType ('subject ' , PARAM_TEXT );
57- $ modform ->addRule ('subject ' , get_string ('required ' ), 'required ' , null , 'client ' );
58- $ modform ->addRule ('subject ' , get_string ('maximumchars ' , '' , 255 ), 'maxlength ' , 255 , 'client ' );
54+ // Show the subject only when this is a new post.
55+ if (empty ($ post ->parentid )) {
56+ $ modform ->addElement ('text ' , 'subject ' , get_string ('subject ' , 'moodleoverflow ' ), 'size="48" ' );
57+ $ modform ->setType ('subject ' , PARAM_TEXT );
58+ $ modform ->addRule ('subject ' , get_string ('required ' ), 'required ' , null , 'client ' );
59+ $ modform ->addRule ('subject ' , get_string ('maximumchars ' , '' , 255 ), 'maxlength ' , 255 , 'client ' );
60+ }
5961
6062 // The message.
6163 $ modform ->addElement (
@@ -125,7 +127,8 @@ public function validation($data, $files) {
125127 if (empty ($ data ['message ' ]['text ' ])) {
126128 $ errors ['message ' ] = get_string ('erroremptymessage ' , 'moodleoverflow ' );
127129 }
128- if (empty ($ data ['subject ' ])) {
130+ // Subject must not be empty when creating a new discussion only.
131+ if (empty ($ data ['subject ' ]) && empty ($ this ->_customdata ['post ' ]->parentid )) {
129132 $ errors ['subject ' ] = get_string ('erroremptysubject ' , 'moodleoverflow ' );
130133 }
131134
0 commit comments