0

I use a php script that inserts data into the jos_content table in order to create an article. In the article content is a textarea with the attribute required.

<textarea name="comment" required></textarea>

But, when I open my article manager and find this created article, there is no required attribute anymore -- everything else is fine. The same thing happens with maxlength.

I use JCE, so I am assuming that it is responsible for killing these attributes somehow.

How can I prevent these attributes from being stripped from my textarea element within my articles?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
user3392725
  • 65
  • 2
  • 9
  • Not familiar with Joomla JCE, but have you tried `required="required"`? According to [a W3.org page](http://www.w3.org/TR/html-markup/textarea.html#textarea.attrs.required) on the attribute, that is also correct. Perhaps your editor is preventing the attribute from appearing because it thinks it is an attribute without a value?? – Crackertastic Mar 20 '14 at 00:36
  • I tried this one too. Tiny editor works fine, but JCE kills it. It's really strange, and I don't know why this is happening. When you save the article, it also removes required from the database. – user3392725 Mar 20 '14 at 00:40
  • are you adding filter="safehtml" for the editor form field settings? Assuming you are using Joomla native MVC form, otherwise please ignore my comment. Edit : Sorry - now my comment sounds irrelevant. – smozgur Mar 20 '14 at 00:50

2 Answers2

0

Have you tried to change the settings of JCE editor. Go to the Editor Global Configuration > Cleanup and Output and set the HTML Validation to NO.

This will affect your code, but it will keep the attributes of textareas in the articles. Of course, you have to set the attribute to have value: required="required".

Or, just use another editor: Tiny etc...

mpavlovic89
  • 749
  • 3
  • 16
  • 37
0

I faced to the same issue. The problem is that JCE will remove all element which do not have any content inside.

In other words, this will be removed:

<textarea name="comment" required></textarea>

And this will not:

<textarea name="comment" required>&nbsp;</textarea>
Jocelyn
  • 277
  • 4
  • 21