Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Problem with "HtmlOneLineField"


Go to End


8 Posts   2623 Views

Avatar
poblom

Community Member, 25 Posts

31 July 2008 at 6:22am

Hi,

I learned the hard way that "HtmlOneLineField" does not work! But using "HtmlEditorField" as an alternativ, if you really only need one row, is wast of space and can be quit confusing for the user.

It seems as you can not change the number of rows delivered by "HtmlEditorField". Or can you? I would be more then greatful if anyone could show me how.

Anyone with a good idea how to deal with this problem?

/PO

Avatar
BLU42 Media

Community Member, 71 Posts

1 August 2008 at 7:21am

Do you have some code to share?

Avatar
poblom

Community Member, 25 Posts

1 August 2008 at 10:10pm


Well, I tried something like this:

$fields->addFieldToTab('Root.Content.Main', new HtmlOneLineField('Sidrubrik', 'Sidrubrik, engelsk'), 'Content');

And all I got back in the Admin was the decoration borders - no field! See attatched file!

/PO

Avatar
BLU42 Media

Community Member, 71 Posts

2 August 2008 at 1:08am

Hi-

My mistake... I did some digging in the api docs and found the field to be deprecated. For a single line you can use HtmlEditorField with this format:

$fields->addFieldToTab(
	'Root.Content.Main',
	new HtmlEditorField(
		$name = 'Sidrubrik',
		$title = 'Sidrubrik, engelsk',
		$rows = 1
	),
	'Content'
);

Let me know if you have success.

Thanks,
John

Avatar
poblom

Community Member, 25 Posts

2 August 2008 at 1:24am

Edited: 02/08/2008 1:28am

Thanks for your suggestion but I have tried setting $rows=1 and it doesn't work, same sad result, 15 rows or none. $rows is a protected variable!

Also tried 'hacking' but my php knowledge is limited so I had to giv in, for now at least.

Thanks anyway!

/PO

Avatar
BLU42 Media

Community Member, 71 Posts

2 August 2008 at 2:57am

Well, I had to dig into this to find out what was going on - didn't want to leave you hanging.

I do think this is more of a css or js issue than php. The html code generated does include inline css to set style: height. There is a min-height specified somewhere on the elements surrounding the actual editor field that's making it look like it's staying propped open.

Maybe someone from Core Dev. can help us to understand how to get this to work?

Avatar
poblom

Community Member, 25 Posts

3 August 2008 at 8:44pm

Yes, you are probably right. I think this is a javascript issue. Looked at the DOM in Firebug and the textarea field itself seems to be there but no iframe!

Going any further is virtually impossible for an amatuer! Core Team??

/PO

Avatar
New Dave

Community Member, 1 Post

28 August 2008 at 3:33pm

Edited: 28/08/2008 3:44pm

Hi, I tried constructing a new HTMLeditorfield, but encountered same problem as above. I checking the html and I'm guessing that this height declaration in the iframe is propping the field open.

<iframe style="width: 100%;height: 220px ...>

HTH. I was just wondering if it was the missing piece of the puzzle.
I was trying to setup a style-able title field, but this minor backend annoyance is... annoying.

Full Markup

<div id="StyledTitle" class="field htmleditor"><label class="left" for="Form_EditForm_StyledTitle">Alternative Title Field with Styling Enabled</label>
<span class="middleColumn"><textarea class="htmleditor typography" rows="1" cols="20" style="width: 97%; height: 16px; display: none;" tinymce="true" id="Form_EditForm_StyledTitle" name="StyledTitle"></textarea>
<span id="mce_editor_0_parent" class="mceEditorContainer"><table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="97%" height="16"><tbody><tr><td align="center">
<iframe style="width: 100%;height: 220px;" allowtransparency="true" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" border="0" class="mceEditorIframe" name="mce_editor_0" id="mce_editor_0" scrolling="no" width="100%" frameborder="0" height="16"></iframe></td></tr></tbody></table></span></span></div>
			
			<div id="Date" class="field calendardate"><label class="left" for="Form_EditForm_Date">Date</label>

cheers,
d.