Adding a class attribute to form label

dmolavi
dmolavi's picture

Joined: 2002-12-05
Posts: 573
Posted: Thu, 2011-01-13 15:21

I'm updating the ecard module, and finally have the JS counter working, enforcing a max length on the message. I'm trying to get the counter to display, but since the form is rendered all at once, I can't find a way to simply insert a string (that doesn't have an associated input) anywhere to show the user. The workaround I found was to assign a class to the textarea's label. The Kohana docs say it should be possible, but when I try:

$group->textarea("text")
      ->label(t("Message"), array("class" => "charsRemaining"))
      ->id("g-text")
      ->maxlength(255)
      ->rules("required")
      ->error_messages("required", t("You must enter a message"));

The class is never assigned to the label. Is there a way to do this in the G3 framework?

--
For Gallery 3 modules and themes, visit GalleryModules.com.
For PHPNuke, phpBB2, and phpBB3 integration help, visit NukedGallery.net.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-01-14 00:52

just guessing here:

$group->textarea("text")
      ->label(t("Message")
      ->class("charsRemaining")
      ->id("g-text")
      ->maxlength(255)
      ->rules("required")
      ->error_messages("required", t("You must enter a message"));

just a guess though. I'll ping bharat.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
dmolavi
dmolavi's picture

Joined: 2002-12-05
Posts: 573
Posted: Fri, 2011-01-14 01:23

That assigns the class to the textarea, not the label.

--
For Gallery 3 modules and themes, visit GalleryModules.com.
For PHPNuke, phpBB2, and phpBB3 integration help, visit NukedGallery.net.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2011-01-19 05:37

You can use jQuery to find the right element once you have the class of the textarea...
---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Wed, 2011-01-19 05:54

it would be much slower than CSS

 
dmolavi
dmolavi's picture

Joined: 2002-12-05
Posts: 573
Posted: Wed, 2011-01-19 17:26

Yeah, I was kinda hoping to avoid jQuery to make this change, and have it done straight in CSS. It's OK for now, though, the little counter just doesn't show a real-time value for how many characters are left.

--
For Gallery 3 modules and themes, visit GalleryModules.com.
For PHPNuke, phpBB2, and phpBB3 integration help, visit NukedGallery.net.