Results 1 to 11 of 11

Thread: Infofield widget

  1. #1

    Default Infofield widget

    Hi,

    I want to create a new field: infoFiled, which is just displaying some information/ help text in the backend. This field should not be stored in the database!

    I've extended the widget class.

    How can I prevent that my field is not saved to the database? It looks that all widgets are getting saved to the database (in Controller class)


    Thanx,
    Frederick

  2. #2
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Infofield widget

    I have requested this as a new feature. This will then support both Information and Help fields, that can be collapsed and closed. This is useful to have a HELP feature at the top of the form for newbies, but then when you know what to do, you can close the field.

    The only way I can think of now, is to create a READ-ONLY field, but it must still exist in the database. Another developer might be able to shed some light. I did this for the catalog extension's calculate field. It's visible, non-editable, but it still exists in the DB with an empty value, as I override the storage value to always just be blank "".

  3. #3

    Default Re: Infofield widget

    Thanx theo.

    Rgds,
    Frederick

  4. #4
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Infofield widget

    of course using some clevel HTML, you could add your own custom HTML into the "help below the field" and then style that accordingly to create the necessary "help" block.

    Also, there is a Help Wizard you can activate next to a field (usually a little warning symbol)

  5. #5
    Community-Moderator xchs's Avatar
    Join Date
    06-20-09.
    Posts
    1,292

    Default Re: Infofield widget

    Quote Originally Posted by thyon
    I have requested this as a new feature.
    I know you've requested this in the tracker but unfortunatly I can not find this ticket anymore (like mentioned here).

    Can you provide a link to the ticket?
    Contao Community Moderator
    → Support options

  6. #6
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Infofield widget

    Hi xchs

    Here is the ticket link. I've also done a kewl mockup of what it could look like. It's pretty much a toss-up to decide if it should be a TOP only instruction system, or PER legend (maybe a link as part of the legend section heading), or if it can be inserted anywhere between fields.

    http://dev.contao.org/issues/2463

  7. #7
    Community-Moderator xchs's Avatar
    Join Date
    06-20-09.
    Posts
    1,292

    Default Re: Infofield widget

    Quote Originally Posted by thyon
    Here is the ticket link.
    http://dev.contao.org/issues/2463
    Ah, fine. Thank you, Thyon.
    Contao Community Moderator
    → Support options

  8. #8
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Infofield widget

    You can also achieve this using the input_field_callback, as that doesn't render a default field, OR require any database entry, as the field is no longer automatically managed by Contao. In this field, you can then add the necessary INFO or HELP or really anything you like.

  9. #9
    New user
    Join Date
    02-24-11.
    Posts
    1

    Default Re: Infofield widget

    Thanx for that Thyon!

    freeyland

    (Problems with my account, had to recreate a new account untill someone sorts out problem)

  10. #10
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Infofield widget

    I thought that developers might want to use this example I created, as it's a really kewl overlooked feature in Contao.

    In the example below I create a non-database field, to use as a help rendering in a section above some of the fields. You have to add the field into the normal palette, but it's callback is used to render it, without any DB activity. You can then add text/html into language strings and pull it all in at runtime. I added text, styles, and an icon to illustrate.

    [attachment=0:9riektkt]dcahelp.jpg[/attachment:9riektkt]

    Code:
    $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['helpmode'] = array
    (
        'input_field_callback'    => array('tl_calendar_invites', 'helpMode')
    );
    
    class tl_calendar_invites extends \Backend
      public function helpMode(\DataContainer $dc, $xlabel)
      {
        $icon = $this->generateImage('show.gif', $GLOBALS['TL_LANG']['tl_calendar_events']['helpmode'][0], ' style="vertical-align:-4px"');
        return '<div class="long">
    <h3><label style="color:#8ab858">'.$icon. ' ' . $GLOBALS['TL_LANG']['tl_calendar_events']['helpmode'][0].'</label></h3>     
    <div class="">'.$GLOBALS['TL_LANG']['tl_calendar_events']['helpmode'][1].'</div>
    </div>';
      }
    …
    }

  11. #11
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Infofield widget

    This is the coolest thing I've ever added to Contao. It really makes it much more user friendly. I've even made it possible to check the activeRecord and switch the help depending on the option you choose. In the screenshot below, if you don't choose the HTML option on the invitation select drop-down, it doesn't show the help at all. This rocks!!!! :geek:

    [attachment=0:243sg8gr]conditionalhelp.jpg[/attachment:243sg8gr]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •