Colin,

Thanks for pointing me in the right direction, we worked on
implementing some of this into core this afternoon, as it seems as
though it might be useful to others.  Both formcontrol textareas and
formcontrol text will have optional titles for the labels and inputs.

~miklb


On May 29, 7:06 am, Colin <[email protected]> wrote:
> HI Mike
>
> You can, sort of, but you'll need to create your own form control to
> actually use it as all the supplied formcontrols don't provide or use
> the title option.
>
> A very simple example...
>
> 1.  Create your own formcontrol.
>
> Lets take the system/admin/formcontrols/formcontrol_text.php as an example.
>
> Copy it to a location used by your plugin.
>
> Modify it and add the title to the label, for example:
>
> ---
> <div<?php echo ($class) ? ' class="' . $class . '"' : ''?><?php echo
> ($id) ? ' id="' . $id . '"' : ''?>>
>         <label title="<?php echo $title; ?>"><?php echo
> $this->caption; ?></label>                             <!----  TITLE
> ADDED HERE -->
>         <input type="text" name="<?php echo $field; ?>" value="<?php
> echo htmlspecialchars($value); ?>">
>         <?php $control->errors_out('<li>%s</li>', '<ul
> class="error">%s</ul>'); ?>
> </div>
> ---
>
> 2.  Add the formcontrol to your plugin configuration page and use it
> and assign your title:
>
> --- filename.plugin/php ---
> [...]
>     public function action_plugin_ui( $plugin_id, $action )
>     {
>         $this->add_template( 'mikes_text', dirname( $this->get_file()
> ) . '/lib/formcontrols/formcontrol_text.php' );  # [1]
>
>         if ( $plugin_id == $this->plugin_id() ) {
>             switch ( $action ) {
>                 case _t( 'Configure' ):
>                 $ui = new FormUI( strtolower( get_class( $this ) ) );
>                     $ui->append( 'text', 'mikestextbox', 'null:null',
> _t( 'Mikes Textbox' ), 'mikes_text' );   # [2]
>                     $ui->mikestextbox->title = "Your title";  #[3]
>                    [...]
> ---
>
> That's it.
>
> Your text box label should now have your title.
>
> WARNING: I've not tested this example. I've just adapted some of my
> own code to illustrate the point.
>
> HTH
> Colin
>
> [1] - This is the path to the location where you've saved your custom
> formcontrol (usually in your plugin dir somewhere).
> [2] - The 5th field must match the first field used in [1].  Change
> the rest of the fields to suit your needs.
> [3] - Setting your custom title.
> [...] - The rest of the code for the plugin
>
> On Fri, May 29, 2009 at 11:15 AM, Michael Bishop <[email protected]> 
> wrote:
>
> > is it possible to add a title to a label in formUI?
>
> > If so, could someone provide a code sample?
>
> > If not, how difficult would it be to add that as an option?
>
> > thanks in advance for any insight.
>
> > ~miklb
>
> --
> Colin Seymour
> Blog:http://www.colinseymour.co.uk
> Tech Stuff:http://www.lildude.co.uk
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to