Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Problem with "HtmlOneLineField"

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

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

Page: 1
Go to End
Author Topic: 2293 Views
  • poblom
    Avatar
    Community Member
    25 Posts

    Problem with "HtmlOneLineField" Link to this post

    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

  • BLU42 Media
    Avatar
    Community Member
    71 Posts

    Re: Problem with "HtmlOneLineField" Link to this post

    Do you have some code to share?

  • poblom
    Avatar
    Community Member
    25 Posts

    Re: Problem with "HtmlOneLineField" Link to this post

    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

  • BLU42 Media
    Avatar
    Community Member
    71 Posts

    Re: Problem with "HtmlOneLineField" Link to this post

    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

  • poblom
    Avatar
    Community Member
    25 Posts

    Re: Problem with "HtmlOneLineField" Link to this post

    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

  • BLU42 Media
    Avatar
    Community Member
    71 Posts

    Re: Problem with "HtmlOneLineField" Link to this post

    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?

  • poblom
    Avatar
    Community Member
    25 Posts

    Re: Problem with "HtmlOneLineField" Link to this post

    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

  • New Dave
    Avatar
    Community Member
    1 Post

    Re: Problem with "HtmlOneLineField" Link to this post

    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.

    2293 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.