PHP Classes

How to disable a select option

Recommend this page to a friend!

      HtmlForm PHP 5  >  All threads  >  How to disable a select option  >  (Un) Subscribe thread alerts  
Subject:How to disable a select option
Summary:How to disable a select option
Messages:18
Author:w. studer
Date:2013-02-06 16:16:07
Update:2013-02-13 10:53:16
 
  1 - 10   11 - 18  

  1. How to disable a select option   Reply   Report abuse  
Picture of w. studer w. studer - 2013-02-06 16:16:07
Hi

For the SELECT form tag, I can define OPTION values.
How this is done is clear.

Now I have the problem that I want to list some items as an OPTION, but DISABLED.
Example about DISABLE usage see http://www.w3schools.com/tags/att_option_disabled.asp

How do I do this with htmlform v0.99 ?

Thx & greetings
Wolfgang

  2. Re: How to disable a select option   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2013-02-06 23:04:04 - In reply to message 1 from w. studer
A very good question indeed ... well ... you got me ... again. :)

Never used that option, so I simply overlooked that possibility and I'll have to extend the setDisabled-methods for checkboxes, radiobuttons and selects for this.

Until than you can try to hack this by brutally using setOptionCssClasses in the wrongest way possible. I'm not sure this works, because I can't try this right now, but you can try to set a value as such for the disabled options:

array('niceclass', 'badclass" disabled="disabled', '" disabled="disabled')

Since I didn't escape double quotes here on purpose, to enable such hacks in cases of emergency, this should work.

I'll add new setDisabled-methods as soon as i get to it.

  3. Re: How to disable a select option   Reply   Report abuse  
Picture of w. studer w. studer - 2013-02-07 09:46:34 - In reply to message 2 from Sebastian Schlapkohl
Well, I think I will wait ;-)

Thx
Wolfgang

  4. Re: How to disable a select option   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2013-02-11 21:33:36 - In reply to message 3 from w. studer
Today I got around to extend the setDisabled-methods of Select, InputChebox and InputRadio.

You can now specifiy a single value or mixed array of indices/values/texts as the first parameter of this method and the hereby identified options will singularily be disabled.

While I was at it I also cleaned up the selected-setters and removed setSelectedValues and setSelectedIndices and such. Now there is only setSelected, which also accepts a single value or a mixed array. This should prove much more convenient than before. Just keep one thing in mind: don't use the same strings for values and text on different options.

Using texts in this context is a little bit nonsensical I have to admit. I'll think a little about it and it may well be, that I kick selection by description alltogether for V1.0, since it's a dirty way of identification anyway.

I also added a default behaviour for JS-enabled validation, where forms with errorneous JS-enabled fields will not be submitted to the server as long as the errors persist.

Guess I've been busy today :)

  5. Re: How to disable a select option   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2013-02-11 22:01:15 - In reply to message 3 from w. studer
Yeah, I think I'll still rework the classes a little bit, this selection problem bugs me out. I'll fix that tomorrow, better wait that out.

  6. Re: How to disable a select option   Reply   Report abuse  
Picture of w. studer w. studer - 2013-02-12 09:21:25 - In reply to message 5 from Sebastian Schlapkohl
;-)

Know that problem very well.

Will wait ;-)

Nut please, provide somewhere (e.g. in the ful zip) an info what has been changed.
Makes our live easier .


Thanks a lot
Wolfgang

  7. Re: How to disable a select option   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2013-02-12 10:50:16 - In reply to message 6 from w. studer
That's what commit messages are for, but unfortunately phpclasses doesn't display them properly. Maybe I should write Manuel about this and ask if he can include a general table of recent changes.

  8. Re: How to disable a select option   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2013-02-12 10:52:16 - In reply to message 6 from w. studer
BTW: A really easy method to see what's new or has been changed is to do a diff on the example file, since I build testcases for everything new features and such can normally be found here quite self-explanatory.

  9. Re: How to disable a select option   Reply   Report abuse  
Picture of w. studer w. studer - 2013-02-12 11:17:54 - In reply to message 8 from Sebastian Schlapkohl
That's a really good idea.
Will keep in mind ;-)

  10. Re: How to disable a select option   Reply   Report abuse  
Picture of Sebastian Schlapkohl Sebastian Schlapkohl - 2013-02-12 14:05:29 - In reply to message 9 from w. studer
I've finished the changes.

These are the commit messages:

I:
- added possibility to disable single options via extended setDisabled-method
- removed all selection-setters in Select, Checkbox, Radio except setSelected
- setSelected and setDisabled now accept single values or arrays, all values may be an index, a value or a text of an option to select/disable, which is determined automatically
- Radio kept the original setSelected(String)

II:
- added setMultipartFormData()
- updated example with setMultipartFormData()
- implemented a reload block in case js-enabled validations are still unresolved

III:
- fixed bug when selecting or disabling via index
- removed possibility to select or disable via description/content of option
- updated testcases and documentation
- included new js-validation behaviour: form will not submit if still js-validation errors present and will scroll to message container if existing
- removed validation output for hidden fields

I wrote Manuel a mail about including commit messages in the file list, let's see what comes out of it :)

From now on only bugfixing till V1.0 ...

 
  1 - 10   11 - 18