OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Make text area field a required one

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Make text area field a required one

Postby piotreba » Thu May 05, 2011 2:32 am

Hello, I modified a little a form of the step 4a during submission, it's the form where you edit supplementary materials' data. I just want it to present title and description so I hid the other fields. But I want the text area field for entering description to be required one, ok I managed to display the asterisk :) but I don't know how to make that field to be processed through validating script against being empty.



Thanks


Peter.
piotreba
 
Posts: 157
Joined: Mon Dec 13, 2010 3:29 pm

Re: Make text area field a required one

Postby jmacgreg » Fri May 06, 2011 2:23 pm

Hi Peter,

This thread should be useful. Let me know if you get stuck.

Cheers,
James
jmacgreg
 
Posts: 4190
Joined: Tue Feb 14, 2006 10:50 am

Re: Make text area field a required one

Postby piotreba » Sat May 07, 2011 10:15 am

Hmm, no, doesn't work.

In the file SuppFileForm.inc.php I added this line:
Code: Select all
$this->addCheck(new FormValidatorLocale($this, 'description', 'required', 'author.submit.suppFile.form.descriptionRequired'));


after this one:
Code: Select all
$this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.suppFile.form.titleRequired'));


and modified the author.xml under locale. I clear data and template cache, but it still let me leave the Brief description field empty. It's textarea field where the <html> tag always resides, but I hope the validation is bright enough to detect that there isn't any real word, just a html tag.
piotreba
 
Posts: 157
Joined: Mon Dec 13, 2010 3:29 pm

Re: Make text area field a required one

Postby mcrider » Wed May 11, 2011 11:56 am

Hi Peter,

What do you mean by there being an <html> tag in your textarea? The FormValidator will consider that text and so it would not return as empty. If you like, you could post your suppFile.tpl file so we can make sure its formatted correctly.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Make text area field a required one

Postby piotreba » Wed May 11, 2011 1:44 pm

This field is text area with html formatting options (tool bar at the bottom of the field). If I press view html code there I can see <html> (in IE 9, not in Firefox).


Here is part needed to be updated in SuppFileForm.inc.php
Code: Select all
// Validation checks for this form
$this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.suppFile.form.titleRequired'));
$this->addCheck(new FormValidatorLocale($this, 'description', 'required', 'author.submit.suppFile.form.descriptionRequired'));
$this->addCheck(new FormValidatorPost($this));



and here a part with text area field code from suppFile.tpl
Code: Select all
<tr valign="top">
   <td width="20%" class="label">{fieldLabel required="true" name="description" key="author.submit.suppFile.briefDescription"}</td>
   <td width="80%" class="value"><textarea name="description[{$formLocale|escape}]" class="textArea" id="description" rows="5" cols="60">{$description[$formLocale]|escape}</textarea></td>
</tr>
piotreba
 
Posts: 157
Joined: Mon Dec 13, 2010 3:29 pm

Re: Make text area field a required one

Postby mcrider » Thu May 12, 2011 2:02 pm

Hi Peter,

TinyMCE is probably interfering with the field and not working properly in IE. Try disabling it by removing case 'author/submitSuppFile': $fields[] = 'description'; break; in plugins/generic/tinymce/TinyMCEPlugin.inc.php (around line 94).

I could only find one other required field in OJS that has TinyMCE on it -- The short description field used when creating an announcement. Would you be able to test whether or not that fails validation when left blank in IE9?

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Make text area field a required one

Postby piotreba » Thu May 12, 2011 2:12 pm

But the validation also fails with firefox :(

There is no <html> tag in this browser, when turning to html preview, the field is empty then, nevertheless the code provided above fails.
piotreba
 
Posts: 157
Joined: Mon Dec 13, 2010 3:29 pm

Re: Make text area field a required one

Postby mcrider » Thu May 12, 2011 3:20 pm

Hi Adam,

Got it -- we're looking at the wrong Form class. Try adding the check to classes/author/form/submit/AuthorSubmitSuppFileForm.inc.php.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Make text area field a required one

Postby piotreba » Fri May 13, 2011 11:26 am

Yes, now it works :)

Thank you!!

But I noticed strange behavior. When an error occurs, the text area field changes so that it doesn't allow to use formatting. It's not just about the supplementary file description, also in other locations, like personal profile details.
piotreba
 
Posts: 157
Joined: Mon Dec 13, 2010 3:29 pm

Re: Make text area field a required one

Postby mcrider » Fri May 13, 2011 11:48 am

mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Make text area field a required one

Postby piotreba » Mon May 16, 2011 10:29 am

It seems to be the same with editUser, the text editor won't show up. In TinyMCEPlugin.inc.php there is
Code: Select all
subscriptionManager/updateUser
and
Code: Select all
manager/updateUser

Shouldn't it be editUser instead updateUser? I change so and the formatting options work.
piotreba
 
Posts: 157
Joined: Mon Dec 13, 2010 3:29 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 3 guests