• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Thu May 13, 2010 2:54 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Fri May 09, 2008 11:20 am
Posts: 701
Location: Lithuania
Hi,
Since CMSMS 1.7.1 class is being added to  input tag, for example for textfield class="cms_textfield" is being added. I need to add the module specific class. How can I do it?

vilkis


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Thu May 13, 2010 3:17 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Fri May 09, 2008 11:20 am
Posts: 701
Location: Lithuania
Ok. One of the ways could be:

Code:
str_replace('class="cms_textfield"', 'class="cms_textfield MY_CLASS"', $this->CreateInputText(....)


vilkis


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Thu May 13, 2010 3:30 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7089
Location: Fernie British Columbia, Canada
Yeah, you can do that.  but with wrapper divs you shouldn't need to.
Jquery and css selectors make having to add classes to specific text fields almost un-necessary.
we added the classes there so that things would be easier to style.

i.e: 

{FrontEndUsers}




easy stuff.

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Thu May 13, 2010 3:59 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Fri May 09, 2008 11:20 am
Posts: 701
Location: Lithuania
It is nice feature for styling as not all browsers support "[type=text]" in css. Using Javascript is also good, but imagine that one wants to  create site that does not need javascript in frontend? Or let say module creates several textfields and one of them should have one class and other one - other. What to do? One has to create additional smarty array of parameters?

Anyway, thank you for the tip.

vilkis


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Wed Aug 18, 2010 9:07 am 
Offline
Forum Members
Forum Members

Joined: Wed May 13, 2009 12:41 pm
Posts: 15
I hope it's okay to reply to this (somewhat) old topic...

In a module a made some time ago I used jquery to validate my selfmade frontend forms... To create a mandatory form field I used
Code:
$this->CreateInputText($id, 'name', '', 10, 255, 'class="mandatory"');


on the frontend I used jquery to validate a fields with the mandatory class.
since CMSMS 1.7.1 this doesn't work anymore because the tag now looks like
Code:
<input type="text" name="id_name" id="id_name" class="cms_textfield" size="10" maxlength="255" class="mandatory" />


Does anybody have a solution for this problem? I don't think str_replace is a very good/clean solution for this problem...

I don't know why the decision is made to add a class to every input field... I think we've now lost a little bit of freedom in module making. I think you should be able to add classes to individual input fields. Is it an option to extend the CreateInput* functions with a addclass? (I know... probably asking a bit too much here...)


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Wed Aug 18, 2010 4:38 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Fri May 09, 2008 11:20 am
Posts: 701
Location: Lithuania
In this situation to use str_replace is the best way. I agree it is strange to generate some string and then replace part of it.
Actually, if you generate a Qjuery code with your module you can do so that a Qjuery recognizes input field by id.

vilkis


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Wed Aug 25, 2010 2:26 pm 
Offline
Forum Members
Forum Members

Joined: Wed Aug 20, 2008 3:04 pm
Posts: 40
Hello,

I've just been bitten by this problem today.  I've just upgraded a site from 1.6.x to 1.8.2 and now all the styling on custom forms within the modules I have created have gone haywire! :(

If the developers of cmsmadesimple are going to force classes and styles upon certain html elements then they also need to supply a way of overriding those styles, imho.  I consider this move to be quite an unnecessary restriction, it makes me not want to use the provided api functions to create my form elements and no one wants that.

It is all well and good for new sites, where we can code within the restrictions, but for sites that have been around for a while it makes it very difficult for me to sell the upgrade...

Anyway, I have a suggestion for manmower, as you're already using jquery within the page this might be the best place to tackle the issue and use jquery itself to add a class to the fields when the page loads.  Something like:

$('.cms_textfield').addClass('mandatory');

I suppose that would have the effect of flagging all the fields with that class as 'mandatory', maybe not quite what you want, but with some thought you'll probably get what you want without having to rewrite all the forms or the scripts that generate them.

Cheers,

          Mark.


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Sat Sep 04, 2010 1:46 am 
IMHO there should be an additional param in the api functions that creates the form inputs to add a custom class attribute.
E.g.

$this->CreateInputText($id, 'name', '', 10, 255, '', 'mandatory foo');

what would result in

class="cms_textfield mandatory foo" size="10" maxlength="255" />

What do you devs think of that?


Last edited by NaN on Sat Sep 04, 2010 1:48 am, edited 1 time in total.

Top
  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Thu Oct 07, 2010 9:45 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Mon Sep 28, 2009 5:25 pm
Posts: 54
NaN wrote:

IMHO there should be an additional param in the api functions that creates the form inputs to add a custom class attribute.
E.g.

$this->CreateInputText($id, 'name', '', 10, 255, '', 'mandatory foo');

what would result in

class="cms_textfield mandatory foo" size="10" maxlength="255" />

What do you devs think of that?



I couldn't have said it better myself


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Fri Oct 08, 2010 2:20 am 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 12280
Location: Arizona
You can't add classes to the form inputs or other elements when creating/editing them anymore?...

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS 1.7.1
PostPosted: Fri Oct 08, 2010 3:10 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Mon Sep 28, 2009 5:25 pm
Posts: 54
Dr.CSS wrote:
You can't add classes to the form inputs or other elements when creating/editing them anymore?...


Some elements you can, and some you can't. Links are the only element I've come across so far where adding a class to it actually works.


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS
PostPosted: Sun Jan 30, 2011 4:20 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Fri Jun 08, 2007 7:29 pm
Posts: 897
Location: 's-Hertogenbosch, Netherlands
[edit]Dr.CSS explains in a later post an answer to this situation. I have removed the code shown in this post. Better if you use DR.CSS's method.[/edit]
I see more people (read developers) seem to have to cope with this situation.
The api description of CreateInputText (at this moment core 1.9.2 is out) seems still to refer to the pre cms_textfield times. The way I solved it is by far from the best method, but it works.
I used in the main module program (ie skeleton.module.php) a copy of the function that prepares the input text field:
Code:
   /**
    * Rewrite of cms_module_CreateInputText() in modform.inc.php
    * Core program has class defined 'cms_textfield' that doesn't allow further design with a class
    */
   function CreateInputText($id, $name, $value='', $size='10', $maxlength='255', $addttext='')
   {
      $value = cms_htmlentities($value);
      $id = cms_htmlentities($id);
      $name = cms_htmlentities($name);
      $size = cms_htmlentities($size);
      $maxlength = cms_htmlentities($maxlength);
      
      $value = str_replace('"', '&quot;', $value);
      
      $text = '<input type="text" name="'.$id.$name.'" id="'.$id.$name.'" value="'.$value.'" size="'.$size.'" maxlength="'.$maxlength.'"';
      if ($addttext != '')
      {
         $text .= ' ' . $addttext;
      }
      else {
         // No additional data, at least set the default class to cms_field
         $text .= ' class="cms_textfield"';
      }
      $text .= " />\n";
      return $text;
   }

In the program that creates the input text field I now have:
Code:
$this->CreateInputText($id, 'name', $name, 40, 60, 'class="cms_textfield required"'));

This allows me to exactly set the class or additional text that I want to, while not passing the 'class=...' gives the default cms_textfield.
I know it overrides the default core version, but this seems to me a stable function anyway.

Duketown


Last edited by Duketown on Wed Feb 02, 2011 9:36 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS
PostPosted: Sun Jan 30, 2011 4:41 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 12280
Location: Arizona
I add classes to forms all the time, it may put them on the div around the input or whatever it is but it is still very useful to me...

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS
PostPosted: Sun Jan 30, 2011 10:03 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Fri Jun 08, 2007 7:29 pm
Posts: 897
Location: 's-Hertogenbosch, Netherlands
Dr.CSS,

A div around the input. I do understand how to do that, but how do I change the background color (for example) of the input field with a div around it, since the cms_textfield overrides it (I don't want to have all input fields with the same background color. Required input fields should have a different color than non required.

Duketown


Top
 Profile  
 
 Post subject: Re: How to add the module specific class to input tag? CMSMS
PostPosted: Sun Jan 30, 2011 11:43 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 12280
Location: Arizona
Like so...

div.required input {background-color:#f2f2f2}

If I see the site it helps tell more of what can be done, that up there is just the tip of what can be done...

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting